net: eth_write_hwaddr: Return error for invalid MACs
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>
diff --git a/net/eth.c b/net/eth.c
index 49458c8..321d5b1 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -218,9 +218,12 @@
}
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;
}