]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net: Fix the rollback test in dev_change_name()
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 15 Nov 2009 23:30:24 +0000 (23:30 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Nov 2009 11:30:35 +0000 (03:30 -0800)
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>
net/core/dev.c

index b8f74cfb1bfdf1365494e87a1b712834f936f287..fe10551d3671053ea6d6a6da57de037f43ad78d0 100644 (file)
@@ -942,14 +942,15 @@ rollback:
        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);
                }
        }