* bonding: fix device leak on error in bond_create()
@ 2010-02-26 15:35 Patrick McHardy
2010-02-26 16:05 ` Andy Gospodarek
2010-02-27 10:52 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Patrick McHardy @ 2010-02-26 15:35 UTC (permalink / raw)
To: Linux Netdev List; +Cc: Jay Vosburgh
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 01.diff --]
[-- Type: text/x-patch, Size: 702 bytes --]
commit f357a5caa0ca29b74811a0fc08efb5ae4aade959
Author: Patrick McHardy <kaber@trash.net>
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.
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 1787e3c..430c022 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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();
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: bonding: fix device leak on error in bond_create()
2010-02-26 15:35 bonding: fix device leak on error in bond_create() Patrick McHardy
@ 2010-02-26 16:05 ` Andy Gospodarek
2010-02-26 16:17 ` Patrick McHardy
2010-02-27 10:52 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Andy Gospodarek @ 2010-02-26 16:05 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Linux Netdev List, Jay Vosburgh
On Fri, Feb 26, 2010 at 04:35:52PM +0100, Patrick McHardy wrote:
> commit f357a5caa0ca29b74811a0fc08efb5ae4aade959
> Author: Patrick McHardy <kaber@trash.net>
> 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.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 1787e3c..430c022 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -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 <andy@greyhouse.net>
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.
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 1787e3c..cd3ea54 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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();
Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: bonding: fix device leak on error in bond_create()
2010-02-26 16:05 ` Andy Gospodarek
@ 2010-02-26 16:17 ` Patrick McHardy
2010-02-26 16:22 ` Andy Gospodarek
0 siblings, 1 reply; 5+ messages in thread
From: Patrick McHardy @ 2010-02-26 16:17 UTC (permalink / raw)
To: Andy Gospodarek; +Cc: Linux Netdev List, Jay Vosburgh
Andy Gospodarek wrote:
> On Fri, Feb 26, 2010 at 04:35:52PM +0100, Patrick McHardy wrote:
>
>> commit f357a5caa0ca29b74811a0fc08efb5ae4aade959
>> Author: Patrick McHardy <kaber@trash.net>
>> 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.
>>
>> Signed-off-by: Patrick McHardy <kaber@trash.net>
>>
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 1787e3c..430c022 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -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 <andy@greyhouse.net>
>
> 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.
I don't care much, but that would be a bug since we'd return
invalid errno codes to userspace.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bonding: fix device leak on error in bond_create()
2010-02-26 16:17 ` Patrick McHardy
@ 2010-02-26 16:22 ` Andy Gospodarek
0 siblings, 0 replies; 5+ messages in thread
From: Andy Gospodarek @ 2010-02-26 16:22 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Linux Netdev List, Jay Vosburgh
On Fri, Feb 26, 2010 at 05:17:40PM +0100, Patrick McHardy wrote:
> Andy Gospodarek wrote:
> > On Fri, Feb 26, 2010 at 04:35:52PM +0100, Patrick McHardy wrote:
> >
> >> commit f357a5caa0ca29b74811a0fc08efb5ae4aade959
> >> Author: Patrick McHardy <kaber@trash.net>
> >> 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.
> >>
> >> Signed-off-by: Patrick McHardy <kaber@trash.net>
> >>
> >> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> >> index 1787e3c..430c022 100644
> >> --- a/drivers/net/bonding/bond_main.c
> >> +++ b/drivers/net/bonding/bond_main.c
> >> @@ -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 <andy@greyhouse.net>
> >
> > 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.
>
> 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....
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bonding: fix device leak on error in bond_create()
2010-02-26 15:35 bonding: fix device leak on error in bond_create() Patrick McHardy
2010-02-26 16:05 ` Andy Gospodarek
@ 2010-02-27 10:52 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2010-02-27 10:52 UTC (permalink / raw)
To: kaber; +Cc: netdev, fubar
From: Patrick McHardy <kaber@trash.net>
Date: Fri, 26 Feb 2010 16:35:52 +0100
> commit f357a5caa0ca29b74811a0fc08efb5ae4aade959
> Author: Patrick McHardy <kaber@trash.net>
> 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.
>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
I think whether we should be checking for negative return values is
not something to gripe over, so I've applied this, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-27 10:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-26 15:35 bonding: fix device leak on error in bond_create() Patrick McHardy
2010-02-26 16:05 ` Andy Gospodarek
2010-02-26 16:17 ` Patrick McHardy
2010-02-26 16:22 ` Andy Gospodarek
2010-02-27 10:52 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.