Commit ff5b2fab authored by Lucas Stach's avatar Lucas Stach Committed by David S. Miller

net: fec: add fallback to random MAC address

If no valid MAC address could be obtained from the hardware,
fall back to a randomly generated one.
Signed-off-by: default avatarPavel Machek <pavel@denx.de>
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e768fb29
...@@ -1038,6 +1038,18 @@ static void fec_get_mac(struct net_device *ndev) ...@@ -1038,6 +1038,18 @@ static void fec_get_mac(struct net_device *ndev)
iap = &tmpaddr[0]; iap = &tmpaddr[0];
} }
/*
* 5) random mac address
*/
if (!is_valid_ether_addr(iap)) {
/* Report it and use a random ethernet address instead */
netdev_err(ndev, "Invalid MAC address: %pM\n", iap);
eth_hw_addr_random(ndev);
netdev_info(ndev, "Using random MAC address: %pM\n",
ndev->dev_addr);
return;
}
memcpy(ndev->dev_addr, iap, ETH_ALEN); memcpy(ndev->dev_addr, iap, ETH_ALEN);
/* Adjust MAC if using macaddr */ /* Adjust MAC if using macaddr */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment