On Wed, 09 Apr 2003 13:51:22 -0700 (PDT) "David S. Miller" <davem@redhat.com> wrote: > From: Stephen Hemminger <shemminger@osdl.org> > Date: Wed, 9 Apr 2003 12:20:02 -0700 > > Here is a third version. It checks register_netdev() which could fail > and moves the register and try_module up to correctly handle the unwind > case. > > Your original patch is in Linus's tree, so you'll need to submit > something relative to that so that I can apply it cleanly. > > Thanks. Here is a diff against BK latest. --- linux-2.5/net/8021q/vlan.c 2003-04-09 14:10:13.000000000 -0700 +++ linux-2.5-vlan/net/8021q/vlan.c 2003-04-09 14:10:52.000000000 -0700 @@ -501,6 +501,15 @@ real_dev->ifindex); #endif + if (register_netdevice(new_dev)) + goto out_free_newdev_priv; + + /* NOTE: We have a reference to the real device, + * so hold on to the reference. May fail if we are being removed + */ + if (!try_module_get(THIS_MODULE)) + goto out_free_unregister; + /* So, got the sucker initialized, now lets place * it into our local structure. */ @@ -514,7 +523,7 @@ if (!grp) { /* need to add a new group */ grp = kmalloc(sizeof(struct vlan_group), GFP_KERNEL); if (!grp) - goto out_free_newdev_priv; + goto out_free_put; /* printk(KERN_ALERT "VLAN REGISTER: Allocated new group.\n"); */ memset(grp, 0, sizeof(struct vlan_group)); @@ -535,24 +544,18 @@ if (real_dev->features & NETIF_F_HW_VLAN_FILTER) real_dev->vlan_rx_add_vid(real_dev, VLAN_ID); - register_netdevice(new_dev); - rtnl_unlock(); - /* NOTE: We have a reference to the real device, - * so hold on to the reference. - */ - if (!try_module_get(THIS_MODULE)) - goto out_module_dying; #ifdef VLAN_DEBUG printk(VLAN_DBG "Allocated new device successfully, returning.\n"); #endif return new_dev; +out_free_put: + module_put(THIS_MODULE); -out_module_dying: - rtnl_lock(); - unregister_netdevice(new_dev); +out_free_unregister: + unregister_netdev(new_dev); out_free_newdev_priv: kfree(new_dev->priv); - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html