Skip to contentSkip to conversation

Do not register ne2k-pci device until initialized

PATCH Applied Lubomir Rintel 5 participants 6 messages May 2, 2009 – May 3, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not register ne2k-pci device until initialized

Doing it in reverse order causes uevent to be sent before we have a MAC address, which confuses udev.

---
 drivers/net/ne2k-pci.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/ne2k-pci.c +3 -4
index eb66f65..7d83896 100644
@@ -374,18 +374,17 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
 	dev->ethtool_ops = &ne2k_pci_ethtool_ops;
 	NS8390_init(dev, 0);
 
+	memcpy(dev->dev_addr, SA_prom, 6);
+	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
+
 	i = register_netdev(dev);
 	if (i)
 		goto err_out_free_netdev;
 
-	for(i = 0; i < 6; i++)
-		dev->dev_addr[i] = SA_prom[i];
 	printk("%s: %s found at %#lx, IRQ %d, %pM.\n",
 	       dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq,
 	       dev->dev_addr);
 
-	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
-
 	return 0;
 
 err_out_free_netdev:
Signature · 1 line
"Excuse all the blood" -- Dead
#2 lore raw

Hi,

Quoted 1 line

Good spotting, that fixes a clear startup race

I saw this and thought that this must be one of those non-singular bugs again... ;)

(I checked for dev_addr manipulations _after_ register_netdev)

And, well...:

smsc911x.c looks like it has the same issue (in case of a non-specified MAC address - invalid EEPROM content).

Dito ucc_geth.c

Dito arm/ixp4xx_eth.c

Dito wireless/netwave_cs.c

Given that several drivers seem to violate this rule: is there a way to add a check against this problem?

Andreas Mohr

maintainer
#3 lore raw

From: Andreas Mohr <[email protected]>
Date: Sat, 2 May 2009 19:58:11 +0200

Quoted 5 lines

And, well...:

smsc911x.c looks like it has the same issue (in case of a non-specified MAC address - invalid EEPROM content).

Quoted 8 lines

Dito ucc_geth.c

Dito arm/ixp4xx_eth.c

Dito wireless/netwave_cs.c

Given that several drivers seem to violate this rule: is there a way to add a check against this problem?

I'm pretty sure we have a valid ethernet address check somewhere already... hmmm..

#4 lore raw
In reply to Andreas Mohr
Quoted 1 line · Andreas Mohr

Dito arm/ixp4xx_eth.c

Right, will have a patch soon (mainline only, IMHO it's not worth it to bother "stable" people because of no practical impact of this bug, especially on this ARM IXP4xx arch).

Thanks.

Signature · 1 line
Krzysztof Halasa