netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] xen-netfront: update num_queues to real created
@ 2015-10-15  2:34 Joe Jin
  2015-10-16 10:56 ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Jin @ 2015-10-15  2:34 UTC (permalink / raw)
  To: wei.liu2, Ian Campbell, David S. Miller, annie.li@oracle.com,
	Konrad Rzeszutek Wilk
  Cc: netdev, xen-devel, stable

Sometimes xennet_create_queues() may failed to created all requested
queues, we need to update num_queues to real created to avoid NULL
pointer dereference.

Signed-off-by: Joe Jin <joe.jin@oracle.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David S. Miller <davem@davemloft.net>
---
 drivers/net/xen-netfront.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f821a97..d580aec 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
 		dev_err(&info->netdev->dev, "no queues\n");
 		return -EINVAL;
 	}
-	return 0;
+	return num_queues;
 }
 
 /* Common code used when first setting up, and when resuming. */
@@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
 	if (info->queues)
 		xennet_destroy_queues(info);
 
-	err = xennet_create_queues(info, num_queues);
-	if (err < 0)
+	/* Update queues number to real created */
+	num_queues = xennet_create_queues(info, num_queues);
+	if (num_queues < 0) {
+		err = num_queues;
 		goto destroy_ring;
+	}
 
 	/* Create shared ring, alloc event channel -- for each queue */
 	for (i = 0; i < num_queues; ++i) {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-16 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-15  2:34 [PATCH 1/1] xen-netfront: update num_queues to real created Joe Jin
2015-10-16 10:56 ` Wei Liu
2015-10-16 12:15   ` Boris Ostrovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).