Xiaotian Feng
2009-Jul-24 09:06 UTC
[Bridge] [PATCH] net/bridge: use kobject_put to release kobject in br_add_if error path
kobject_init_and_add will alloc memory for kobj->name, so in br_add_if error path, simply use kobject_del will not free memory for kobj->name. Fix by using kobject_put instead, kobject_put will internally calls kobject_del and frees memory for kobj->name. Signed-off-by: Xiaotian Feng <dfeng at redhat.com> --- net/bridge/br_if.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 8a96672..eb404dc 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -424,7 +424,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) err2: br_fdb_delete_by_port(br, p, 1); err1: - kobject_del(&p->kobj); + kobject_put(&p->kobj); err0: dev_set_promiscuity(dev, -1); put_back: -- 1.6.2.5
Stephen Hemminger
2009-Jul-24 15:36 UTC
[Bridge] [PATCH] net/bridge: use kobject_put to release kobject in br_add_if error path
On Fri, 24 Jul 2009 17:06:32 +0800 Xiaotian Feng <dfeng at redhat.com> wrote:> kobject_init_and_add will alloc memory for kobj->name, so in br_add_if > error path, simply use kobject_del will not free memory for kobj->name. > Fix by using kobject_put instead, kobject_put will internally calls > kobject_del and frees memory for kobj->name. > > Signed-off-by: Xiaotian Feng <dfeng at redhat.com> > --- > net/bridge/br_if.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c > index 8a96672..eb404dc 100644 > --- a/net/bridge/br_if.c > +++ b/net/bridge/br_if.c > @@ -424,7 +424,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) > err2: > br_fdb_delete_by_port(br, p, 1); > err1: > - kobject_del(&p->kobj); > + kobject_put(&p->kobj); > err0: > dev_set_promiscuity(dev, -1); > put_back:I assume you tested this by doing something like adding two interfaces with the same MAC address to a bridge. Acked-by: Stephen Hemminger <shemminger at vyatta.com> --
David Miller
2009-Jul-27 02:21 UTC
[Bridge] [PATCH] net/bridge: use kobject_put to release kobject in br_add_if error path
From: Stephen Hemminger <shemminger at linux-foundation.org> Date: Fri, 24 Jul 2009 08:36:07 -0700> On Fri, 24 Jul 2009 17:06:32 +0800 > Xiaotian Feng <dfeng at redhat.com> wrote: > >> kobject_init_and_add will alloc memory for kobj->name, so in br_add_if >> error path, simply use kobject_del will not free memory for kobj->name. >> Fix by using kobject_put instead, kobject_put will internally calls >> kobject_del and frees memory for kobj->name. >> >> Signed-off-by: Xiaotian Feng <dfeng at redhat.com>...> > I assume you tested this by doing something like adding two interfaces > with the same MAC address to a bridge. > > Acked-by: Stephen Hemminger <shemminger at vyatta.com>Applied, thanks!