Subject: [PATCH 8/32] rt2x00: Invalid memory allocation check

From: Ivo van Doorn <[email-masked]>
Date: Fri, 28 Apr 2006 00:02:58 +0200

From: Ivo van Doorn <[email-masked]>

Fix invalid check when allocating the memory for
the rate structures. Instead of the channel pointer
the rates pointer should be verified.

Signed-off-by: Ivo van Doorn <[email-masked]>

diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-27 21:40:43.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-27 21:41:20.000000000 +0200
@@ -2036,7 +2036,7 @@ rt2400pci_init_hw(struct rt2x00_pci *rt2
 	hw->modes->num_rates = 4;
 	hw->modes->rates =
 		kzalloc(sizeof(struct ieee80211_rate) * 4, GFP_KERNEL);
-	if (!hw->modes->channels)
+	if (!hw->modes->rates)
 		goto exit_free_channels;
 
 	/*
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-27 21:40:43.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-27 21:41:20.000000000 +0200
@@ -2236,7 +2236,7 @@ rt2500pci_init_hw(struct rt2x00_pci *rt2
 		hw->modes->rates =
 			kzalloc((sizeof(struct ieee80211_rate) * 12),
 			GFP_KERNEL);
-		if (!hw->modes->channels)
+		if (!hw->modes->rates)
 			goto exit_free_channels;
 	} else {
 		hw->num_modes = 3;
@@ -2255,7 +2255,7 @@ rt2500pci_init_hw(struct rt2x00_pci *rt2
 		hw->modes->rates =
 			kzalloc((sizeof(struct ieee80211_rate) * 12),
 			GFP_KERNEL);
-		if (!hw->modes->channels)
+		if (!hw->modes->rates)
 			goto exit_free_channels;
 	}
 
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:40:43.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:41:20.000000000 +0200
@@ -1931,7 +1931,7 @@ rt2500usb_init_hw(struct rt2x00_usb *rt2
 		hw->modes->rates =
 			kzalloc((sizeof(struct ieee80211_rate) * 12),
 			GFP_KERNEL);
-		if (!hw->modes->channels)
+		if (!hw->modes->rates)
 			goto exit_free_channels;
 	} else {
 		hw->num_modes = 3;
@@ -1950,7 +1950,7 @@ rt2500usb_init_hw(struct rt2x00_usb *rt2
 		hw->modes->rates =
 			kzalloc((sizeof(struct ieee80211_rate) * 12),
 			GFP_KERNEL);
-		if (!hw->modes->channels)
+		if (!hw->modes->rates)
 			goto exit_free_channels;
 	}