[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190430002817.10785-4-tobin@kernel.org>
Date: Tue, 30 Apr 2019 10:28:17 +1000
From: "Tobin C. Harding" <tobin@...nel.org>
To: "David S. Miller" <davem@...emloft.net>
Cc: "Tobin C. Harding" <tobin@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Tyler Hicks <tyhicks@...onical.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ido Schimmel <idosch@...lanox.com>,
Alexander Duyck <alexander.h.duyck@...el.com>,
Florian Fainelli <f.fainelli@...il.com>,
Wang Hai <wanghai26@...wei.com>,
YueHaibing <yuehaibing@...wei.com>,
Amritha Nambiar <amritha.nambiar@...el.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] net-sysfs: Fix error path for kobject_init_and_add()
Currently error return from kobject_init_and_add() is not followed by a
call to kobject_put(). This means there is a memory leak.
Add call to kobject_put() in error path of kobject_init_and_add().
Signed-off-by: Tobin C. Harding <tobin@...nel.org>
---
net/core/net-sysfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 8f8b7b6c2945..9d4e3f47b789 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -925,8 +925,10 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
kobj->kset = dev->queues_kset;
error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL,
"rx-%u", index);
- if (error)
+ if (error) {
+ kobject_put(kobj);
return error;
+ }
dev_hold(queue->dev);
@@ -1462,8 +1464,10 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index)
kobj->kset = dev->queues_kset;
error = kobject_init_and_add(kobj, &netdev_queue_ktype, NULL,
"tx-%u", index);
- if (error)
+ if (error) {
+ kobject_put(kobj);
return error;
+ }
dev_hold(queue->dev);
--
2.21.0
Powered by blists - more mailing lists