p54: fix a null pointer dereference bug
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 710-p54_rssi_crash_fix.patch
1 --- a/drivers/net/wireless/p54/eeprom.c
2 +++ b/drivers/net/wireless/p54/eeprom.c
3 @@ -524,10 +524,13 @@ err_data:
4
5 struct p54_rssi_db_entry *p54_rssi_find(struct p54_common *priv, const u16 freq)
6 {
7 - struct p54_rssi_db_entry *entry = (void *)(priv->rssi_db->data +
8 - priv->rssi_db->offset);
9 + struct p54_rssi_db_entry *entry;
10 int i, found = -1;
11
12 + if (!priv->rssi_db)
13 + return &p54_rssi_default;
14 +
15 + entry = (void *)(priv->rssi_db->data + priv->rssi_db->offset);
16 for (i = 0; i < priv->rssi_db->entries; i++) {
17 if (!same_band(freq, entry[i].freq))
18 continue;