From 325e42185846fd6d82fdedc4010c6b2605fa7eb2 Mon Sep 17 00:00:00 2001 From: Alexander Beregalov Date: Sun, 22 Nov 2009 20:40:52 -0800 Subject: [PATCH] Au1x00: fix crash when trying register_netdev() [ Upstream commit 63edaf647607795a065e6956a79c47f500dc8447 ] Andreas Lohre reported that the driver crashes when trying to register_netdev(), he sugessted to move dev->netdev_ops initialization before calling register_netdev(), it worked for him. Reported-by: Andreas Lohre Signed-off-by: Alexander Beregalov Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/au1000_eth.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index d3c734f4d679..2f6ae784a36f 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c @@ -1089,7 +1089,14 @@ static struct net_device * au1000_probe(int port_num) return NULL; } - if ((err = register_netdev(dev)) != 0) { + dev->base_addr = base; + dev->irq = irq; + dev->netdev_ops = &au1000_netdev_ops; + SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops); + dev->watchdog_timeo = ETH_TX_TIMEOUT; + + err = register_netdev(dev); + if (err != 0) { printk(KERN_ERR "%s: Cannot register net device, error %d\n", DRV_NAME, err); free_netdev(dev); @@ -1207,12 +1214,6 @@ static struct net_device * au1000_probe(int port_num) aup->tx_db_inuse[i] = pDB; } - dev->base_addr = base; - dev->irq = irq; - dev->netdev_ops = &au1000_netdev_ops; - SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops); - dev->watchdog_timeo = ETH_TX_TIMEOUT; - /* * The boot code uses the ethernet controller, so reset it to start * fresh. au1000_init() expects that the device is in reset state. -- 2.39.5