Skip to content

Commit

Permalink
net: handle errors from device_rename
Browse files Browse the repository at this point in the history
device_rename can fail with -EEXIST or -ENOMEM, so handle any
problems.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed May 15, 2008
1 parent 8f40f67 commit dcc9977
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,11 @@ int dev_change_name(struct net_device *dev, char *newname)
strlcpy(dev->name, newname, IFNAMSIZ);

rollback:
device_rename(&dev->dev, dev->name);
err = device_rename(&dev->dev, dev->name);
if (err) {
memcpy(dev->name, oldname, IFNAMSIZ);
return err;
}

write_lock_bh(&dev_base_lock);
hlist_del(&dev->name_hlist);
Expand Down

0 comments on commit dcc9977

Please sign in to comment.