p54: fix a NULL pointer dereference bug
authorFelix Fietkau <nbd@openwrt.org>
Sun, 27 Feb 2011 21:19:22 +0000 (22:19 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 28 Feb 2011 19:06:54 +0000 (14:06 -0500)
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>
Acked-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/p54/eeprom.c

index f54e15fcd623e3e62dea6eccde604cee6759d9de..13d750da930119bc7bdfc4faf4ad322c6cf467e2 100644 (file)
@@ -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;