Subject: [PATCH] bcm43xx-d80211: protect tx_stat callback from uninitialized device

From: Michael Buesch <[email-masked]>
Date: Mon, 10 Apr 2006 02:25:00 +0200

diff --git a/drivers/net/wireless/bcm43xx-d80211/bcm43xx_main.c b/drivers/net/wireless/bcm43xx-d80211/bcm43xx_main.c
index 043a5cf..f0f4f78 100644
--- a/drivers/net/wireless/bcm43xx-d80211/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx-d80211/bcm43xx_main.c
@@ -4128,15 +4128,19 @@ static int bcm43xx_net_get_tx_stats(stru
 {
 	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 	unsigned long flags;
+	int err = -ENODEV;
 
 	bcm43xx_lock(bcm, flags);
-	if (bcm43xx_using_pio(bcm))
-		bcm43xx_pio_get_tx_stats(bcm, stats);
-	else
-		bcm43xx_dma_get_tx_stats(bcm, stats);
+	if (likely(bcm->initialized)) {
+		if (bcm43xx_using_pio(bcm))
+			bcm43xx_pio_get_tx_stats(bcm, stats);
+		else
+			bcm43xx_dma_get_tx_stats(bcm, stats);
+		err = 0;
+	}
 	bcm43xx_unlock(bcm, flags);
 
-	return 0;
+	return err;
 }
 
 static int bcm43xx_net_get_stats(struct net_device *net_dev,

-- 
Greetings Michael.