Subject: Re: [PATCHv2 net-next] net: fec: add fallback to random MAC address

From: Sergei Shtylyov <[email-masked]>
Date: Mon, 03 Jun 2013 15:30:14 +0400

Hello.

On 03-06-2013 14:38, Lucas Stach wrote:

> If no valid MAC address could be obtained from the hardware,
> fall back to a randomly generated one.

> Signed-off-by: Pavel Machek <[email-masked]>
> Signed-off-by: Lucas Stach <[email-masked]>
> ---
>   drivers/net/ethernet/freescale/fec_main.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)

> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 927f4c6..0063761 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1039,6 +1039,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);

    This was you'll copy an invalid address over the random one again.

WBR, Sergei