Commit 7af3db78 authored by Wang Chen's avatar Wang Chen Committed by David S. Miller

ipv6: Fix using after dev_put()

Patrick McHardy pointed it out.
Signed-off-by: default avatarWang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5ae7b444
...@@ -443,6 +443,7 @@ static struct net_device *ip6mr_reg_vif(void) ...@@ -443,6 +443,7 @@ static struct net_device *ip6mr_reg_vif(void)
if (dev_open(dev)) if (dev_open(dev))
goto failure; goto failure;
dev_hold(dev);
return dev; return dev;
failure: failure:
...@@ -616,6 +617,7 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock) ...@@ -616,6 +617,7 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock)
err = dev_set_allmulti(dev, 1); err = dev_set_allmulti(dev, 1);
if (err) { if (err) {
unregister_netdevice(dev); unregister_netdevice(dev);
dev_put(dev);
return err; return err;
} }
break; break;
...@@ -624,10 +626,11 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock) ...@@ -624,10 +626,11 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock)
dev = dev_get_by_index(&init_net, vifc->mif6c_pifi); dev = dev_get_by_index(&init_net, vifc->mif6c_pifi);
if (!dev) if (!dev)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
dev_put(dev);
err = dev_set_allmulti(dev, 1); err = dev_set_allmulti(dev, 1);
if (err) if (err) {
dev_put(dev);
return err; return err;
}
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -651,7 +654,6 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock) ...@@ -651,7 +654,6 @@ static int mif6_add(struct mif6ctl *vifc, int mrtsock)
/* And finish update writing critical data */ /* And finish update writing critical data */
write_lock_bh(&mrt_lock); write_lock_bh(&mrt_lock);
dev_hold(dev);
v->dev = dev; v->dev = dev;
#ifdef CONFIG_IPV6_PIMSM_V2 #ifdef CONFIG_IPV6_PIMSM_V2
if (v->flags & MIFF_REGISTER) if (v->flags & MIFF_REGISTER)
......
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