wil6210: update cid boundary check of wil_find_cid/_by_idx()
authorAlexei Avshalom Lazar <ailizaro@codeaurora.org>
Sun, 16 Jun 2019 07:26:03 +0000 (10:26 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 27 Jun 2019 17:50:28 +0000 (20:50 +0300)
The return value of wil_find_cid()/wil_find_cid_by_idx() is
validated with the lower boundary value.
Check the upper boundary value as well.

Signed-off-by: Alexei Avshalom Lazar <ailizaro@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/wil6210/cfg80211.c
drivers/net/wireless/ath/wil6210/main.c

index f94fe42..64da2be 100644 (file)
@@ -380,8 +380,8 @@ static int wil_cfg80211_get_station(struct wiphy *wiphy,
 
        wil_dbg_misc(wil, "get_station: %pM CID %d MID %d\n", mac, cid,
                     vif->mid);
-       if (cid < 0)
-               return cid;
+       if (!wil_cid_valid(wil, cid))
+               return -ENOENT;
 
        rc = wil_cid_fill_sinfo(vif, cid, sinfo);
 
@@ -417,7 +417,7 @@ static int wil_cfg80211_dump_station(struct wiphy *wiphy,
        int rc;
        int cid = wil_find_cid_by_idx(wil, vif->mid, idx);
 
-       if (cid < 0)
+       if (!wil_cid_valid(wil, cid))
                return -ENOENT;
 
        ether_addr_copy(mac, wil->sta[cid].addr);
index f7b9e6b..173561f 100644 (file)
@@ -340,7 +340,7 @@ static void _wil6210_disconnect_complete(struct wil6210_vif *vif,
                wil_dbg_misc(wil,
                             "Disconnect complete %pM, CID=%d, reason=%d\n",
                             bssid, cid, reason_code);
-               if (cid >= 0) /* disconnect 1 peer */
+               if (wil_cid_valid(wil, cid)) /* disconnect 1 peer */
                        wil_disconnect_cid_complete(vif, cid, reason_code);
        } else { /* all */
                wil_dbg_misc(wil, "Disconnect complete all\n");
@@ -452,7 +452,7 @@ static void _wil6210_disconnect(struct wil6210_vif *vif, const u8 *bssid,
                cid = wil_find_cid(wil, vif->mid, bssid);
                wil_dbg_misc(wil, "Disconnect %pM, CID=%d, reason=%d\n",
                             bssid, cid, reason_code);
-               if (cid >= 0) /* disconnect 1 peer */
+               if (wil_cid_valid(wil, cid)) /* disconnect 1 peer */
                        wil_disconnect_cid(vif, cid, reason_code);
        } else { /* all */
                wil_dbg_misc(wil, "Disconnect all\n");