[PATCH 1/2] Revert "net-sysfs: Fix memory leak in netdev_register_kobject"

From: Wang Hai
Date: Fri Apr 12 2019 - 00:40:56 EST


This reverts commit 6b70fc94afd165342876e53fc4b2f7d085009945.

The reverted bugfix will cause another issue.
Reported by syzbot+6024817a931b2830bc93@xxxxxxxxxxxxxxxxxxxxxxxxxx
See https://syzkaller.appspot.com/x/log.txt?x=1737671b200000 for
details.

Signed-off-by: Wang Hai <wanghai26@xxxxxxxxxx>
---
net/core/net-sysfs.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index f8f9430..8f8b7b6 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1747,20 +1747,16 @@ int netdev_register_kobject(struct net_device *ndev)

error = device_add(dev);
if (error)
- goto error_put_device;
+ return error;

error = register_queue_kobjects(ndev);
- if (error)
- goto error_device_del;
+ if (error) {
+ device_del(dev);
+ return error;
+ }

pm_runtime_set_memalloc_noio(dev, true);

- return 0;
-
-error_device_del:
- device_del(dev);
-error_put_device:
- put_device(dev);
return error;
}

--
1.8.3.1