linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John W. Linville" <linville@tuxdriver.com>
To: linux-wireless@vger.kernel.org
Cc: "John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH] ath5k: avoid oops when ah_capabilities.cap_mode not set
Date: Wed, 17 Oct 2007 15:03:00 -0400	[thread overview]
Message-ID: <1192647780430-git-send-email-linville@tuxdriver.com> (raw)

ah_capabilities.cap_mode doesn't get set for some cards, causing the
kernel to oops when these unknown/unsupported cards are inserted.
Add some NULL checks to avoid this.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 drivers/net/wireless/ath5k/base.c |    3 +++
 drivers/net/wireless/ath5k/hw.c   |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index da72056..40f5ce6 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -2007,6 +2007,9 @@ static int ath_getchannels(struct ieee80211_hw *hw)
 		}
 
 		hw_rates = ath5k_hw_get_rate_table(ah, mode->mode);
+		if (!hw_rates)
+			return -EINVAL;
+
 		mode->num_rates    = ath_copy_rates(mode->rates, hw_rates,
 			max_r);
 		mode->num_channels = ath_copy_channels(ah, mode->channels,
diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c
index 504f642..7202e50 100644
--- a/drivers/net/wireless/ath5k/hw.c
+++ b/drivers/net/wireless/ath5k/hw.c
@@ -670,6 +670,8 @@ int ath5k_hw_reset(struct ath_hw *hal, enum ieee80211_if_types op_mode,
 				/*Get rate table for this operation mode*/
 				rt = ath5k_hw_get_rate_table(hal,
 						MODE_IEEE80211B);
+				if (!rt)
+					return -EINVAL;
 
 				/*Write rate duration table*/
 				for (i = 0; i < rt->rate_count; i++) {
@@ -695,6 +697,8 @@ int ath5k_hw_reset(struct ath_hw *hal, enum ieee80211_if_types op_mode,
 				rt = ath5k_hw_get_rate_table(hal,
 				    channel->val & CHANNEL_TURBO ?
 				    MODE_ATHEROS_TURBO : MODE_ATHEROS_TURBOG);
+				if (!rt)
+					return -EINVAL;
 
 				/* Write rate duration table */
 				for (i = 0; i < rt->rate_count; i++)
-- 
1.5.2.4


             reply	other threads:[~2007-10-17 19:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17 19:03 John W. Linville [this message]
2007-10-17 21:36 ` [PATCH] ath5k: avoid oops when ah_capabilities.cap_mode not set Luis R. Rodriguez
2007-11-20 23:25   ` Kyle McMartin
2007-11-20 23:47     ` Luis R. Rodriguez
2007-11-20 23:53       ` Luis R. Rodriguez
2007-11-20 23:46   ` Kyle McMartin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1192647780430-git-send-email-linville@tuxdriver.com \
    --to=linville@tuxdriver.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).