Patchwork [V2] bgmac: validate MAC addr

login
register
mail settings
Submitter Rafał Miłecki
Date Feb. 7, 2013, 10:14 a.m.
Message ID <1360232078-21872-1-git-send-email-zajec5@gmail.com>
Download mbox | patch
Permalink /patch/218876/
State Superseded
Delegated to: David Miller
Headers show

Comments

Rafał Miłecki - Feb. 7, 2013, 10:14 a.m.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
V2: generate random addr
---
 drivers/net/ethernet/broadcom/bgmac.c |    6 ++++++
 1 file changed, 6 insertions(+)
Florian Fainelli - Feb. 7, 2013, 10:19 a.m.
On 02/07/2013 11:14 AM, Rafał Miłecki wrote:
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

This is looking good, however some commit message is desirable, 
especially as you are no longer just validating the ethernet MAC 
address, but also generating a new one. Something along those lines 
would probably be enough:

"This patch changes bgmac_probe() to check for a valid Ethernet MAC 
address and in case it is not, will generate a valid random one, such 
that the adapter is still usable."

Thanks!

> ---
> V2: generate random addr
> ---
>   drivers/net/ethernet/broadcom/bgmac.c |    6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
> index d08a4af..f90d1dc 100644
> --- a/drivers/net/ethernet/broadcom/bgmac.c
> +++ b/drivers/net/ethernet/broadcom/bgmac.c
> @@ -1318,6 +1318,12 @@ static int bgmac_probe(struct bcma_device *core)
>   		return -ENOTSUPP;
>   	}
>   
> +	if (!is_valid_ether_addr(mac)) {
> +		dev_err(&core->dev, "Invalid MAC addr: %pM\n", mac);
> +		eth_random_addr(mac);
> +		dev_warn(&core->dev, "Using random MAC: %pM\n", mac);
> +	}
> +
>   	/* Allocation and references */
>   	net_dev = alloc_etherdev(sizeof(*bgmac));
>   	if (!net_dev)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index d08a4af..f90d1dc 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1318,6 +1318,12 @@  static int bgmac_probe(struct bcma_device *core)
 		return -ENOTSUPP;
 	}
 
+	if (!is_valid_ether_addr(mac)) {
+		dev_err(&core->dev, "Invalid MAC addr: %pM\n", mac);
+		eth_random_addr(mac);
+		dev_warn(&core->dev, "Using random MAC: %pM\n", mac);
+	}
+
 	/* Allocation and references */
 	net_dev = alloc_etherdev(sizeof(*bgmac));
 	if (!net_dev)