Commit f9cc1eb4 authored by Qiushi Wu's avatar Qiushi Wu Committed by Khalid Elmously

bonding: Fix reference count leak in bond_sysfs_slave_add.

BugLink: https://bugs.launchpad.net/bugs/1883917

commit a068aab4 upstream.

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 "b8eb7183" fixed a similar problem.

Fixes: 07699f9a ("bonding: add sysfs /slave dir for bond slave devices.")
Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
Acked-by: default avatarJay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 9959e082
...@@ -153,8 +153,10 @@ int bond_sysfs_slave_add(struct slave *slave) ...@@ -153,8 +153,10 @@ int bond_sysfs_slave_add(struct slave *slave)
err = kobject_init_and_add(&slave->kobj, &slave_ktype, err = kobject_init_and_add(&slave->kobj, &slave_ktype,
&(slave->dev->dev.kobj), "bonding_slave"); &(slave->dev->dev.kobj), "bonding_slave");
if (err) if (err) {
kobject_put(&slave->kobj);
return err; return err;
}
for (a = slave_attrs; *a; ++a) { for (a = slave_attrs; *a; ++a) {
err = sysfs_create_file(&slave->kobj, &((*a)->attr)); err = sysfs_create_file(&slave->kobj, &((*a)->attr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment