Patchwork [net-next,2/7] net: call add_device_randomness() only after successful mac change

login
register
mail settings
Submitter Jiri Pirko
Date Jan. 1, 2013, 1:30 p.m.
Message ID <1357047019-1037-3-git-send-email-jiri@resnulli.us>
Download mbox | patch
Permalink /patch/208907/
State Accepted
Delegated to: David Miller
Headers show

Comments

Jiri Pirko - Jan. 1, 2013, 1:30 p.m.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 net/core/dev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 21c5b97..c85e32b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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);