Skip to content

Commit

Permalink
net: bareudp: add missing error handling for bareudp_link_config()
Browse files Browse the repository at this point in the history
.dellink does not get called after .newlink fails,
bareudp_newlink() must undo what bareudp_configure()
has done if bareudp_link_config() fails.

v2: call bareudp_dellink(), like bareudp_dev_create() does

Fixes: 571912c ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
kuba-moo committed Jan 6, 2021
1 parent 0d136f5 commit 94bcfdb
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions drivers/net/bareudp.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,20 @@ static int bareudp_link_config(struct net_device *dev,
return 0;
}

static void bareudp_dellink(struct net_device *dev, struct list_head *head)
{
struct bareudp_dev *bareudp = netdev_priv(dev);

list_del(&bareudp->next);
unregister_netdevice_queue(dev, head);
}

static int bareudp_newlink(struct net *net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
struct bareudp_conf conf;
LIST_HEAD(list_kill);
int err;

err = bareudp2info(data, &conf, extack);
Expand All @@ -662,17 +671,14 @@ static int bareudp_newlink(struct net *net, struct net_device *dev,

err = bareudp_link_config(dev, tb);
if (err)
return err;
goto err_unconfig;

return 0;
}

static void bareudp_dellink(struct net_device *dev, struct list_head *head)
{
struct bareudp_dev *bareudp = netdev_priv(dev);

list_del(&bareudp->next);
unregister_netdevice_queue(dev, head);
err_unconfig:
bareudp_dellink(dev, &list_kill);
unregister_netdevice_many(&list_kill);
return err;
}

static size_t bareudp_get_size(const struct net_device *dev)
Expand Down

0 comments on commit 94bcfdb

Please sign in to comment.