]>
Commit | Line | Data |
---|---|---|
38568109 GKH |
1 | From foo@baz Thu Mar 28 21:54:17 CET 2019 |
2 | From: YueHaibing <yuehaibing@huawei.com> | |
3 | Date: Tue, 19 Mar 2019 10:16:53 +0800 | |
4 | Subject: net-sysfs: call dev_hold if kobject_init_and_add success | |
5 | ||
6 | From: YueHaibing <yuehaibing@huawei.com> | |
7 | ||
8 | [ Upstream commit a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e ] | |
9 | ||
10 | In netdev_queue_add_kobject and rx_queue_add_kobject, | |
11 | if sysfs_create_group failed, kobject_put will call | |
12 | netdev_queue_release to decrease dev refcont, however | |
13 | dev_hold has not be called. So we will see this while | |
14 | unregistering dev: | |
15 | ||
16 | unregister_netdevice: waiting for bcsh0 to become free. Usage count = -1 | |
17 | ||
18 | Reported-by: Hulk Robot <hulkci@huawei.com> | |
19 | Fixes: d0d668371679 ("net: don't decrement kobj reference count on init failure") | |
20 | Signed-off-by: YueHaibing <yuehaibing@huawei.com> | |
21 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
22 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
23 | --- | |
24 | net/core/net-sysfs.c | 6 ++++-- | |
25 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
26 | ||
27 | --- a/net/core/net-sysfs.c | |
28 | +++ b/net/core/net-sysfs.c | |
29 | @@ -934,6 +934,8 @@ static int rx_queue_add_kobject(struct n | |
30 | if (error) | |
31 | return error; | |
32 | ||
33 | + dev_hold(queue->dev); | |
34 | + | |
35 | if (dev->sysfs_rx_queue_group) { | |
36 | error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group); | |
37 | if (error) { | |
38 | @@ -943,7 +945,6 @@ static int rx_queue_add_kobject(struct n | |
39 | } | |
40 | ||
41 | kobject_uevent(kobj, KOBJ_ADD); | |
42 | - dev_hold(queue->dev); | |
43 | ||
44 | return error; | |
45 | } | |
46 | @@ -1472,6 +1473,8 @@ static int netdev_queue_add_kobject(stru | |
47 | if (error) | |
48 | return error; | |
49 | ||
50 | + dev_hold(queue->dev); | |
51 | + | |
52 | #ifdef CONFIG_BQL | |
53 | error = sysfs_create_group(kobj, &dql_group); | |
54 | if (error) { | |
55 | @@ -1481,7 +1484,6 @@ static int netdev_queue_add_kobject(stru | |
56 | #endif | |
57 | ||
58 | kobject_uevent(kobj, KOBJ_ADD); | |
59 | - dev_hold(queue->dev); | |
60 | ||
61 | return 0; | |
62 | } |