From: Jay Vosburgh Date: Wed, 30 Jan 2008 02:07:45 +0000 (-0800) Subject: bonding: fix NULL pointer deref in startup processing X-Git-Tag: v2.6.25-rc1~1065^2~33 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=4fe4763cd8cacd81d892193efb48b99c99c15323;p=linux-2.6-omap-h63xx.git bonding: fix NULL pointer deref in startup processing Fix the "are we creating a duplicate" check to not compare the name if the name is NULL (meaning that the system should select a name). Bug reported by Benny Amorsen . Signed-off-by: Jay Vosburgh Signed-off-by: Jeff Garzik Signed-off-by: David S. Miller --- diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 65c7ebafaac..81b45740ed7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4896,14 +4896,16 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond down_write(&bonding_rwsem); /* Check to see if the bond already exists. */ - list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) - if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) { - printk(KERN_ERR DRV_NAME + if (name) { + list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) + if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) { + printk(KERN_ERR DRV_NAME ": cannot add bond %s; it already exists\n", - name); - res = -EPERM; - goto out_rtnl; - } + name); + res = -EPERM; + goto out_rtnl; + } + } bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", ether_setup);