Messages in this thread Patch in this message | | | From | "Tobin C. Harding" <> | Subject | [PATCH 3/3] net-sysfs: Fix error path for kobject_init_and_add() | Date | Tue, 30 Apr 2019 10:28:17 +1000 |
| |
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@kernel.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
| |