net: call add_device_randomness() only after successful mac change
authorJiri Pirko <jiri@resnulli.us>
Tue, 1 Jan 2013 03:30:14 +0000 (03:30 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Jan 2013 06:37:35 +0000 (22:37 -0800)
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c

index 21c5b976dcf3b649f49c15298dc545cf3daa5004..c85e32b30f0447a800d4a36fd36c527fe7007876 100644 (file)
@@ -5020,10 +5020,11 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
        if (!netif_device_present(dev))
                return -ENODEV;
        err = ops->ndo_set_mac_address(dev, sa);
-       if (!err)
-               call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
+       if (err)
+               return err;
+       call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
        add_device_randomness(dev->dev_addr, dev->addr_len);
-       return err;
+       return 0;
 }
 EXPORT_SYMBOL(dev_set_mac_address);