linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@openwrt.org>
To: linux-wireless@vger.kernel.org
Cc: linville@tuxdriver.com, chunkeey@googlemail.com
Subject: [PATCH] p54: fix a NULL pointer dereference bug
Date: Sun, 27 Feb 2011 22:19:22 +0100	[thread overview]
Message-ID: <1298841562-62496-1-git-send-email-nbd@openwrt.org> (raw)

If the RSSI calibration table was not found or not parsed properly,
priv->rssi_db will be NULL, p54_rssi_find needs to be able to deal
with that.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/p54/eeprom.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c
index f54e15f..13d750d 100644
--- a/drivers/net/wireless/p54/eeprom.c
+++ b/drivers/net/wireless/p54/eeprom.c
@@ -524,10 +524,13 @@ err_data:
 
 struct p54_rssi_db_entry *p54_rssi_find(struct p54_common *priv, const u16 freq)
 {
-	struct p54_rssi_db_entry *entry = (void *)(priv->rssi_db->data +
-						   priv->rssi_db->offset);
+	struct p54_rssi_db_entry *entry;
 	int i, found = -1;
 
+	if (!priv->rssi_db)
+		return &p54_rssi_default;
+
+	entry = (void *)(priv->rssi_db->data + priv->rssi_db->offset);
 	for (i = 0; i < priv->rssi_db->entries; i++) {
 		if (!same_band(freq, entry[i].freq))
 			continue;
-- 
1.7.3.2


             reply	other threads:[~2011-02-27 21:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-27 21:19 Felix Fietkau [this message]
2011-02-28 12:08 ` [PATCH] p54: fix a NULL pointer dereference bug Christian Lamparter
2011-02-28 13:29   ` Felix Fietkau
2011-03-01 17:30     ` Christian Lamparter

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=1298841562-62496-1-git-send-email-nbd@openwrt.org \
    --to=nbd@openwrt.org \
    --cc=chunkeey@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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).