Commit d1892e4e authored by Tobias Klauser's avatar Tobias Klauser Committed by David S. Miller

rtnl: simplify error return path in rtnl_create_link()

There is only one possible error path which reaches the err label, so
return ERR_PTR(-ENOMEM) directly if alloc_netdev_mqs() fails. This also
allows to omit the err variable.
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 017b29c3
...@@ -2358,7 +2358,6 @@ struct net_device *rtnl_create_link(struct net *net, ...@@ -2358,7 +2358,6 @@ struct net_device *rtnl_create_link(struct net *net,
const char *ifname, unsigned char name_assign_type, const char *ifname, unsigned char name_assign_type,
const struct rtnl_link_ops *ops, struct nlattr *tb[]) const struct rtnl_link_ops *ops, struct nlattr *tb[])
{ {
int err;
struct net_device *dev; struct net_device *dev;
unsigned int num_tx_queues = 1; unsigned int num_tx_queues = 1;
unsigned int num_rx_queues = 1; unsigned int num_rx_queues = 1;
...@@ -2373,11 +2372,10 @@ struct net_device *rtnl_create_link(struct net *net, ...@@ -2373,11 +2372,10 @@ struct net_device *rtnl_create_link(struct net *net,
else if (ops->get_num_rx_queues) else if (ops->get_num_rx_queues)
num_rx_queues = ops->get_num_rx_queues(); num_rx_queues = ops->get_num_rx_queues();
err = -ENOMEM;
dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type, dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type,
ops->setup, num_tx_queues, num_rx_queues); ops->setup, num_tx_queues, num_rx_queues);
if (!dev) if (!dev)
goto err; return ERR_PTR(-ENOMEM);
dev_net_set(dev, net); dev_net_set(dev, net);
dev->rtnl_link_ops = ops; dev->rtnl_link_ops = ops;
...@@ -2403,9 +2401,6 @@ struct net_device *rtnl_create_link(struct net *net, ...@@ -2403,9 +2401,6 @@ struct net_device *rtnl_create_link(struct net *net,
dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP])); dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
return dev; return dev;
err:
return ERR_PTR(err);
} }
EXPORT_SYMBOL(rtnl_create_link); EXPORT_SYMBOL(rtnl_create_link);
......
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