bonding: fix device leak on error in bond_create()
Subsystems (3)
commit f357a5caa0ca29b74811a0fc08efb5ae4aade959
Author: Patrick McHardy <[email protected]> Date: Thu Feb 25 20:21:10 2010 +0100
bonding: fix device leak on error in bond_create()
When the register_netdevice() call fails, the newly allocated device is not freed.
drivers/net/bonding/bond_main.c +2 -0
@@ -4946,6 +4946,8 @@ int bond_create(struct net *net, const char *name) } res =register_netdevice (bond_dev); +if (res <0 ) + goto out_netdev; out:rtnl_unlock ();
Andy Gospodarek
Acked-byQuoted 16 lines · Patrick McHardy
commit
f357a5caa0ca29b74811a0fc08efb5ae4aade959Author: Patrick McHardy <[email protected]> Date: Thu Feb 25 20:21:10 2010 +0100bonding: fix device leak on error in
bond_create()When the
register_netdevice()call fails, the newly allocated device is not freed.Signed-off-by Patrick McHardy <[email protected]>drivers/net/bonding/bond_main.c +0
-0
drivers/net/bonding/bond_main.c int bond_create(struct net *net, const char *name) · line 4953
Quoted 8 lines
drivers/net/bonding/bond_main.c +2
-0@@ -4946,6 +4946,8 @@ int bond_create(struct net *net, const char *name) } res =register_netdevice (bond_dev); +if (res <0 ) + goto out_netdev; out:rtnl_unlock ();
Seems like a good idea. I know register_netdevice is always supposed to return a value < 0 on error, but this would work if it didn't for some reason.
drivers/net/bonding/bond_main.c +2 -0
@@ -4946,6 +4946,8 @@ int bond_create(struct net *net, const char *name) } res =register_netdevice (bond_dev); +if (res) + goto out_netdev; out:rtnl_unlock ();
Quoted 24 lines · Andy Gospodarek
Quoted 22 lines · Patrick McHardy
commit
f357a5caa0ca29b74811a0fc08efb5ae4aade959Author: Patrick McHardy <[email protected]> Date: Thu Feb 25 20:21:10 2010 +0100bonding: fix device leak on error in
bond_create()When the
register_netdevice()call fails, the newly allocated device is not freed.Signed-off-by Patrick McHardy <[email protected]>drivers/net/bonding/bond_main.c +2
-0@@ -4946,6 +4946,8 @@ int bond_create(struct net *net, const char *name) } res =register_netdevice (bond_dev); +if (res <0 ) + goto out_netdev;
Quoted 8 lines
drivers/net/bonding/bond_main.c int bond_create(struct net *net, const char *name) · line 4953
Quoted 2 lines
drivers/net/bonding/bond_main.c +0
-0out:rtnl_unlock ();Acked-by Andy Gospodarek <[email protected]>Seems like a good idea. I know
register_netdeviceis always supposed to return a value < 0 on error, but this would work if it didn't for some reason.
I don't care much, but that would be a bug since we'd return invalid errno codes to userspace.
Quoted 30 lines · Patrick McHardy
Quoted 29 lines · Andy Gospodarek
Quoted 16 lines · Patrick McHardy
commit
f357a5caa0ca29b74811a0fc08efb5ae4aade959Author: Patrick McHardy <[email protected]> Date: Thu Feb 25 20:21:10 2010 +0100bonding: fix device leak on error in
bond_create()When the
register_netdevice()call fails, the newly allocated device is not freed.Signed-off-by Patrick McHardy <[email protected]>drivers/net/bonding/bond_main.c +0
-0drivers/net/bonding/bond_main.c int bond_create(struct net *net, const char *name) · line 4953
Quoted 8 lines
drivers/net/bonding/bond_main.c +2
-0@@ -4946,6 +4946,8 @@ int bond_create(struct net *net, const char *name) } res =register_netdevice (bond_dev); +if (res <0 ) + goto out_netdev; out:rtnl_unlock ();Acked-by Andy Gospodarek <[email protected]>
Quoted 6 lines
Quoted 3 lines
Seems like a good idea. I know
register_netdeviceis always supposed to return a value < 0 on error, but this would work if it didn't for some reason.I don't care much, but that would be a bug since we'd return invalid errno codes to userspace.
Then I guess the bonding driver would probably not be the last to know if someone snuck a bug into register_netdevice....
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Fri, 26 Feb 2010 16:35:52 +0100
Quoted 10 lines
commit
f357a5caa0ca29b74811a0fc08efb5ae4aade959Author: Patrick McHardy <[email protected]> Date: Thu Feb 25 20:21:10 2010 +0100bonding: fix device leak on error in
bond_create()When the
register_netdevice()call fails, the newly allocated device is not freed.Signed-off-by Patrick McHardy <[email protected]>
I think whether we should be checking for negative return values is not something to gripe over, so I've applied this, thanks!