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>
This commit is contained in:
Benoît Thébaudeau 2012-08-10 07:56:21 +00:00 committed by Joe Hershberger
parent 185f7d9afc
commit 460f949f89

View file

@ -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;
}