[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20090925143308.7f38227d@s6510>
Date: Fri, 25 Sep 2009 14:33:08 -0700
From: Stephen Hemminger <shemminger@...tta.com>
To: Jeff Hansen <x@...fhansen.com>
Cc: netdev@...r.kernel.org, jeff@...fhansen.com,
Dave Miller <davem@...emloft.net>,
Jeff Hansen <x@...fhansen.com>
Subject: Re: [PATCH] [bridge] Fix double-free in br_add_if.
On Fri, 25 Sep 2009 14:25:24 -0600
Jeff Hansen <x@...fhansen.com> wrote:
> There is a potential double-kfree in net/bridge/br_if.c. If br_fdb_insert
> fails, then the kobject is put back (which calls kfree due to the kobject
> release), and then kfree is called again on the net_bridge_port. This
> patch fixes the crash.
>
> Signed-off-by: Jeff Hansen <x@...fhansen.com>
> ---
> net/bridge/br_if.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
> index eb404dc..1becec1 100644
> --- a/net/bridge/br_if.c
> +++ b/net/bridge/br_if.c
> @@ -368,7 +368,7 @@ done:
> int br_add_if(struct net_bridge *br, struct net_device *dev)
> {
> struct net_bridge_port *p;
> - int err = 0;
> + int err = 0, kobj_initted = 0;
>
> if (dev->flags & IFF_LOOPBACK || dev->type != ARPHRD_ETHER)
> return -EINVAL;
> @@ -391,6 +391,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
> SYSFS_BRIDGE_PORT_ATTR);
> if (err)
> goto err0;
> + kobj_initted = 1;
>
> err = br_fdb_insert(br, p, dev->dev_addr);
> if (err)
> @@ -429,7 +430,8 @@ err0:
> dev_set_promiscuity(dev, -1);
> put_back:
> dev_put(dev);
> - kfree(p);
> + if (!kobj_initted)
> + kfree(p);
> return err;
> }
>
I'll look at it, probably needs fixing, but the code style with condition
variables is out of place in this code.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists