]> err.no Git - linux-2.6/commitdiff
[PATCH] ieee80211: division by zero fix
authorJiri Benc <jbenc@suse.cz>
Mon, 10 Oct 2005 17:16:53 +0000 (19:16 +0200)
committerJeff Garzik <jgarzik@pobox.com>
Tue, 18 Oct 2005 21:25:36 +0000 (17:25 -0400)
This fixes division by zero bug in ieee80211_wx_get_scan().

Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
net/ieee80211/ieee80211_wx.c

index ee7a70a132500c5834c8bb8d5e826f2bb8c0c235..1ce7af9bec35a167b8e17512ec7ab716a2013549 100644 (file)
@@ -152,15 +152,18 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
                iwe.u.qual.level = 0;
        } else {
                iwe.u.qual.level = network->stats.rssi;
-               iwe.u.qual.qual =
-                   (100 *
-                    (ieee->perfect_rssi - ieee->worst_rssi) *
-                    (ieee->perfect_rssi - ieee->worst_rssi) -
-                    (ieee->perfect_rssi - network->stats.rssi) *
-                    (15 * (ieee->perfect_rssi - ieee->worst_rssi) +
-                     62 * (ieee->perfect_rssi - network->stats.rssi))) /
-                   ((ieee->perfect_rssi - ieee->worst_rssi) *
-                    (ieee->perfect_rssi - ieee->worst_rssi));
+               if (ieee->perfect_rssi == ieee->worst_rssi)
+                       iwe.u.qual.qual = 100;
+               else
+                       iwe.u.qual.qual =
+                           (100 *
+                            (ieee->perfect_rssi - ieee->worst_rssi) *
+                            (ieee->perfect_rssi - ieee->worst_rssi) -
+                            (ieee->perfect_rssi - network->stats.rssi) *
+                            (15 * (ieee->perfect_rssi - ieee->worst_rssi) +
+                             62 * (ieee->perfect_rssi - network->stats.rssi))) /
+                           ((ieee->perfect_rssi - ieee->worst_rssi) *
+                            (ieee->perfect_rssi - ieee->worst_rssi));
                if (iwe.u.qual.qual > 100)
                        iwe.u.qual.qual = 100;
                else if (iwe.u.qual.qual < 1)