]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.68/xen-netfront-improve-error-handling-during-initialization.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.68 / xen-netfront-improve-error-handling-during-initialization.patch
CommitLineData
95244f99
GKH
1From foo@baz Wed Dec 6 17:39:55 CET 2017
2From: Ross Lagerwall <ross.lagerwall@citrix.com>
3Date: Wed, 8 Feb 2017 10:57:37 +0000
4Subject: xen-netfront: Improve error handling during initialization
5
6From: Ross Lagerwall <ross.lagerwall@citrix.com>
7
8
9[ Upstream commit e2e004acc7cbe3c531e752a270a74e95cde3ea48 ]
10
11This fixes a crash when running out of grant refs when creating many
12queues across many netdevs.
13
14* If creating queues fails (i.e. there are no grant refs available),
15call xenbus_dev_fatal() to ensure that the xenbus device is set to the
16closed state.
17* If no queues are created, don't call xennet_disconnect_backend as
18netdev->real_num_tx_queues will not have been set correctly.
19* If setup_netfront() fails, ensure that all the queues created are
20cleaned up, not just those that have been set up.
21* If any queues were set up and an error occurs, call
22xennet_destroy_queues() to clean up the napi context.
23* If any fatal error occurs, unregister and destroy the netdev to avoid
24leaving around a half setup network device.
25
26Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
27Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
28Signed-off-by: David S. Miller <davem@davemloft.net>
29Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
30Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31---
32 drivers/net/xen-netfront.c | 29 +++++++++++------------------
33 1 file changed, 11 insertions(+), 18 deletions(-)
34
35--- a/drivers/net/xen-netfront.c
36+++ b/drivers/net/xen-netfront.c
37@@ -1854,27 +1854,19 @@ static int talk_to_netback(struct xenbus
38 xennet_destroy_queues(info);
39
40 err = xennet_create_queues(info, &num_queues);
41- if (err < 0)
42- goto destroy_ring;
43+ if (err < 0) {
44+ xenbus_dev_fatal(dev, err, "creating queues");
45+ kfree(info->queues);
46+ info->queues = NULL;
47+ goto out;
48+ }
49
50 /* Create shared ring, alloc event channel -- for each queue */
51 for (i = 0; i < num_queues; ++i) {
52 queue = &info->queues[i];
53 err = setup_netfront(dev, queue, feature_split_evtchn);
54- if (err) {
55- /* setup_netfront() will tidy up the current
56- * queue on error, but we need to clean up
57- * those already allocated.
58- */
59- if (i > 0) {
60- rtnl_lock();
61- netif_set_real_num_tx_queues(info->netdev, i);
62- rtnl_unlock();
63- goto destroy_ring;
64- } else {
65- goto out;
66- }
67- }
68+ if (err)
69+ goto destroy_ring;
70 }
71
72 again:
73@@ -1964,9 +1956,10 @@ abort_transaction_no_dev_fatal:
74 xenbus_transaction_end(xbt, 1);
75 destroy_ring:
76 xennet_disconnect_backend(info);
77- kfree(info->queues);
78- info->queues = NULL;
79+ xennet_destroy_queues(info);
80 out:
81+ unregister_netdev(info->netdev);
82+ xennet_free_netdev(info->netdev);
83 return err;
84 }
85