can: vxcan: Use common error handling code in vxcan_newlink()
Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
aa4f3c660a
commit
48794a82c0
|
@ -227,10 +227,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
|
||||||
netif_carrier_off(peer);
|
netif_carrier_off(peer);
|
||||||
|
|
||||||
err = rtnl_configure_link(peer, ifmp);
|
err = rtnl_configure_link(peer, ifmp);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
unregister_netdevice(peer);
|
goto unregister_network_device;
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* register first device */
|
/* register first device */
|
||||||
if (tb[IFLA_IFNAME])
|
if (tb[IFLA_IFNAME])
|
||||||
|
@ -239,10 +237,8 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
|
||||||
snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
|
snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
|
||||||
|
|
||||||
err = register_netdevice(dev);
|
err = register_netdevice(dev);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
unregister_netdevice(peer);
|
goto unregister_network_device;
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
netif_carrier_off(dev);
|
netif_carrier_off(dev);
|
||||||
|
|
||||||
|
@ -254,6 +250,10 @@ static int vxcan_newlink(struct net *net, struct net_device *dev,
|
||||||
rcu_assign_pointer(priv->peer, dev);
|
rcu_assign_pointer(priv->peer, dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
unregister_network_device:
|
||||||
|
unregister_netdevice(peer);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vxcan_dellink(struct net_device *dev, struct list_head *head)
|
static void vxcan_dellink(struct net_device *dev, struct list_head *head)
|
||||||
|
|
Loading…
Reference in New Issue