* [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add.
@ 2020-05-28 3:10 wu000273
2020-05-28 16:18 ` Jay Vosburgh
2020-05-28 18:08 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: wu000273 @ 2020-05-28 3:10 UTC (permalink / raw)
To: kjlu
Cc: wu000273, Jay Vosburgh, Veaceslav Falico, Andy Gospodarek,
David S. Miller, Jakub Kicinski, sfeldma, netdev, linux-kernel
From: Qiushi Wu <wu000273@umn.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@umn.edu>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add.
2020-05-28 3:10 [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add wu000273
@ 2020-05-28 16:18 ` Jay Vosburgh
2020-05-28 18:08 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jay Vosburgh @ 2020-05-28 16:18 UTC (permalink / raw)
To: wu000273
Cc: kjlu, Veaceslav Falico, Andy Gospodarek, David S. Miller,
Jakub Kicinski, sfeldma, netdev, linux-kernel
wu000273@umn.edu wrote:
>From: Qiushi Wu <wu000273@umn.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@umn.edu>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add.
2020-05-28 3:10 [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add wu000273
2020-05-28 16:18 ` Jay Vosburgh
@ 2020-05-28 18:08 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-05-28 18:08 UTC (permalink / raw)
To: wu000273
Cc: kjlu, j.vosburgh, vfalico, andy, kuba, sfeldma, netdev, linux-kernel
From: wu000273@umn.edu
Date: Wed, 27 May 2020 22:10:29 -0500
> From: Qiushi Wu <wu000273@umn.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@umn.edu>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-28 18:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 3:10 [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add wu000273
2020-05-28 16:18 ` Jay Vosburgh
2020-05-28 18:08 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).