Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

via-rhine: Assign random MAC address if necessary

Roger Luethi has had several reports of Rhine NICs providing
an invalid MAC address. If so, assign a random MAC address so
the hardware can still be used.

Tested as a standalone interface, as carrier for ppp, and as a
bonding slave.

Original-patch-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Joe Perches and committed by
David S. Miller
482e3feb df4511fe

+7 -5
+7 -5
drivers/net/via-rhine.c
··· 838 838 839 839 for (i = 0; i < 6; i++) 840 840 dev->dev_addr[i] = ioread8(ioaddr + StationAddr + i); 841 - memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 842 841 843 - if (!is_valid_ether_addr(dev->perm_addr)) { 844 - rc = -EIO; 845 - dev_err(&pdev->dev, "Invalid MAC address\n"); 846 - goto err_out_unmap; 842 + if (!is_valid_ether_addr(dev->dev_addr)) { 843 + /* Report it and use a random ethernet address instead */ 844 + netdev_err(dev, "Invalid MAC address: %pM\n", dev->dev_addr); 845 + random_ether_addr(dev->dev_addr); 846 + netdev_info(dev, "Using random MAC address: %pM\n", 847 + dev->dev_addr); 847 848 } 849 + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 848 850 849 851 /* For Rhine-I/II, phy_id is loaded from EEPROM */ 850 852 if (!phy_id)