Commit 3add94a5 authored by Stephen Hemminger's avatar Stephen Hemminger

[VLAN]: More device registry error handling fixes.

parent b1d7a6ca
...@@ -501,6 +501,15 @@ static struct net_device *register_vlan_device(const char *eth_IF_name, ...@@ -501,6 +501,15 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
real_dev->ifindex); real_dev->ifindex);
#endif #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 /* So, got the sucker initialized, now lets place
* it into our local structure. * it into our local structure.
*/ */
...@@ -514,7 +523,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name, ...@@ -514,7 +523,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
if (!grp) { /* need to add a new group */ if (!grp) { /* need to add a new group */
grp = kmalloc(sizeof(struct vlan_group), GFP_KERNEL); grp = kmalloc(sizeof(struct vlan_group), GFP_KERNEL);
if (!grp) if (!grp)
goto out_free_newdev_priv; goto out_free_put;
/* printk(KERN_ALERT "VLAN REGISTER: Allocated new group.\n"); */ /* printk(KERN_ALERT "VLAN REGISTER: Allocated new group.\n"); */
memset(grp, 0, sizeof(struct vlan_group)); memset(grp, 0, sizeof(struct vlan_group));
...@@ -535,24 +544,18 @@ static struct net_device *register_vlan_device(const char *eth_IF_name, ...@@ -535,24 +544,18 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
if (real_dev->features & NETIF_F_HW_VLAN_FILTER) if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
real_dev->vlan_rx_add_vid(real_dev, VLAN_ID); real_dev->vlan_rx_add_vid(real_dev, VLAN_ID);
register_netdevice(new_dev);
rtnl_unlock(); 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 #ifdef VLAN_DEBUG
printk(VLAN_DBG "Allocated new device successfully, returning.\n"); printk(VLAN_DBG "Allocated new device successfully, returning.\n");
#endif #endif
return new_dev; return new_dev;
out_free_put:
module_put(THIS_MODULE);
out_module_dying: out_free_unregister:
rtnl_lock(); unregister_netdev(new_dev);
unregister_netdevice(new_dev);
out_free_newdev_priv: out_free_newdev_priv:
kfree(new_dev->priv); kfree(new_dev->priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment