Skip to content

Commit

Permalink
net: Fix the rollback test in dev_change_name()
Browse files Browse the repository at this point in the history
net: Fix the rollback test in dev_change_name()

In dev_change_name() an err variable is used for storing the original
call_netdevice_notifiers() errno (negative) and testing for a rollback
error later, but the test for non-zero is wrong, because the err might
have positive value as well - from dev_alloc_name(). It means the
rollback for a netdevice with a number > 0 will never happen. (The err
test is reordered btw. to make it more readable.)

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 16, 2009
1 parent e29d436 commit 91e9c07
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,15 @@ int dev_change_name(struct net_device *dev, const char *newname)
ret = notifier_to_errno(ret);

if (ret) {
if (err) {
printk(KERN_ERR
"%s: name change rollback failed: %d.\n",
dev->name, ret);
} else {
/* err >= 0 after dev_alloc_name() or stores the first errno */
if (err >= 0) {
err = ret;
memcpy(dev->name, oldname, IFNAMSIZ);
goto rollback;
} else {
printk(KERN_ERR
"%s: name change rollback failed: %d.\n",
dev->name, ret);
}
}

Expand Down

0 comments on commit 91e9c07

Please sign in to comment.