p54: potential signedness issue in p54_parse_rssical()
authorDan Carpenter <dan.carpenter@oracle.com>
Sun, 2 Dec 2012 10:36:09 +0000 (13:36 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 3 Dec 2012 18:51:59 +0000 (13:51 -0500)
"entries" is unsigned here, so it is never less than zero.  In theory,
len could be less than offset so I have added a check for that.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/p54/eeprom.c

index 1ef1bfe6a9d7845822cef3413e680de03c2774c9..d43e3740e45d95e4b55bc3af085747dcf346c04b 100644 (file)
@@ -541,8 +541,9 @@ static int p54_parse_rssical(struct ieee80211_hw *dev,
                entries = (len - offset) /
                        sizeof(struct pda_rssi_cal_ext_entry);
 
-               if ((len - offset) % sizeof(struct pda_rssi_cal_ext_entry) ||
-                   entries <= 0) {
+               if (len < offset ||
+                   (len - offset) % sizeof(struct pda_rssi_cal_ext_entry) ||
+                   entries == 0) {
                        wiphy_err(dev->wiphy, "invalid rssi database.\n");
                        goto err_data;
                }