net: eth_write_hwaddr: Return error for invalid MACs
authorBenoît Thébaudeau <benoit.thebaudeau@advansee.com>
Fri, 10 Aug 2012 07:56:21 +0000 (07:56 +0000)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 27 Sep 2012 17:21:36 +0000 (12:21 -0500)
If dev->enetaddr was supposed to be set with dev->write_hwaddr() but the MAC
address was not valid, return an error.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
net/eth.c

index 49458c8db914b96aa082920ed800639b73fcbb2a..321d5b18fd842d3d5df52549b2647ab8fb9ef816 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -218,9 +218,12 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
        }
 
        if (dev->write_hwaddr &&
-                       !eth_mac_skip(eth_number) &&
-                       is_valid_ether_addr(dev->enetaddr))
+                       !eth_mac_skip(eth_number)) {
+               if (!is_valid_ether_addr(dev->enetaddr))
+                       return -1;
+
                ret = dev->write_hwaddr(dev);
+       }
 
        return ret;
 }