bonding: Fix reference count leak in bond_sysfs_slave_add.
authorQiushi Wu <wu000273@umn.edu>
Thu, 28 May 2020 03:10:29 +0000 (22:10 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jun 2020 06:16:46 +0000 (08:16 +0200)
commitcd678077be57378ef2764453478c4694e9c07c6e
treea17e693c043d549745b6ab14d7c13c4714bd6cdb
parent0dee5beb6c802c16bb2cfc94976c1e215a681427
bonding: Fix reference count leak in bond_sysfs_slave_add.

commit a068aab42258e25094bc2c159948d263ed7d7a77 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 "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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/bonding/bond_sysfs_slave.c