]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
bgmac: validate (and random if needed) MAC addr
authorRafał Miłecki <zajec5@gmail.com>
Thu, 7 Feb 2013 00:27:17 +0000 (00:27 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Feb 2013 22:42:19 +0000 (17:42 -0500)
This adds check for a valid Ethernet MAC address and in case it is not,
it will generate a valid random one, such that the adapter is still
usable.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bgmac.c

index 23c8d4a21ccf1505a402f7c55fabda0ce59adf2d..380084bad129e1fbb4a3c395f03d3eda90773748 100644 (file)
@@ -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)