[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2426.1590682689@famine>
Date: Thu, 28 May 2020 09:18:09 -0700
From: Jay Vosburgh <jay.vosburgh@...onical.com>
To: wu000273@....edu
cc: kjlu@....edu, Veaceslav Falico <vfalico@...il.com>,
Andy Gospodarek <andy@...yhouse.net>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
"sfeldma@...ulusnetworks.com" <sfeldma@...ulusnetworks.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add.
wu000273@....edu wrote:
>From: Qiushi Wu <wu000273@....edu>
>
>kobject_init_and_add() takes reference even when it fails.
>If this function returns an error, kobject_put() must be called to
>properly clean up the memory associated with the object. Previous
>commit "b8eb718348b8" fixed a similar problem.
>
>Fixes: 07699f9a7c8d ("bonding: add sysfs /slave dir for bond slave devices.")
>Signed-off-by: Qiushi Wu <wu000273@....edu>
Acked-by: Jay Vosburgh <jay.vosburgh@...onical.com>
>---
> drivers/net/bonding/bond_sysfs_slave.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
>index 007481557191..9b8346638f69 100644
>--- a/drivers/net/bonding/bond_sysfs_slave.c
>+++ b/drivers/net/bonding/bond_sysfs_slave.c
>@@ -149,8 +149,10 @@ int bond_sysfs_slave_add(struct slave *slave)
>
> err = kobject_init_and_add(&slave->kobj, &slave_ktype,
> &(slave->dev->dev.kobj), "bonding_slave");
>- if (err)
>+ if (err) {
>+ kobject_put(&slave->kobj);
> return err;
>+ }
>
> for (a = slave_attrs; *a; ++a) {
> err = sysfs_create_file(&slave->kobj, &((*a)->attr));
>--
>2.17.1
>
Powered by blists - more mailing lists