Skip to content

Commit

Permalink
net: fec: add fallback to random MAC address
Browse files Browse the repository at this point in the history
If no valid MAC address could be obtained from the hardware,
fall back to a randomly generated one.

Signed-off-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Lucas Stach authored and David S. Miller committed Jun 5, 2013
1 parent e768fb2 commit ff5b2fa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/net/ethernet/freescale/fec_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,18 @@ static void fec_get_mac(struct net_device *ndev)
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);

/* Adjust MAC if using macaddr */
Expand Down

0 comments on commit ff5b2fa

Please sign in to comment.