Skip to contentSkip to conversation

wil6210: fix unsigned cid comparison with >= 0

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Aug 29, 2018 – Sep 6, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wil6210: fix unsigned cid comparison with >= 0

The comparison of cid >= 0 is always true because cid is of type u8 (8 bits, unsigned).

Fix this by removing such comparison and updating the type of variable cid to u8 in the caller function.

Addresses-Coverity-ID: 1473079 ("Unsigned compared against 0")

Fixes b9010f105f21 ("wil6210: add FT roam support for AP and station")
---
 drivers/net/wireless/ath/wil6210/wil6210.h | 2 +-
 drivers/net/wireless/ath/wil6210/wmi.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/wil6210/wil6210.h +1 -1
index cf6a691..abb8201 100644
@@ -455,7 +455,7 @@ static inline void parse_cidxtid(u8 cidxtid, u8 *cid, u8 *tid)
  */
 static inline bool wil_cid_valid(u8 cid)
 {
-	return (cid >= 0 && cid < WIL6210_MAX_CID);
+	return cid < WIL6210_MAX_CID;
 }
 
 struct wil6210_mbox_ring {
drivers/net/wireless/ath/wil6210/wmi.c +1 -1
index c3ad8e4..4859f0e 100644
@@ -1177,7 +1177,7 @@ static void wmi_evt_ring_en(struct wil6210_vif *vif, int id, void *d, int len)
 	u8 vri = evt->ring_index;
 	struct wireless_dev *wdev = vif_to_wdev(vif);
 	struct wil_sta_info *sta;
-	int cid;
+	u8 cid;
 	struct key_params params;
 
 	wil_dbg_wmi(wil, "Enable vring %d MID %d\n", vri, vif->mid);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 10 lines · Gustavo A. R. Silva

The comparison of cid >= 0 is always true because cid is of type u8 (8 bits, unsigned).

Fix this by removing such comparison and updating the type of variable cid to u8 in the caller function.

Addresses-Coverity-ID: 1473079 ("Unsigned compared against 0")

Fixes b9010f105f21 ("wil6210: add FT roam support for AP and station")

Patch applied to ath-next branch of ath.git, thanks.

49925f247016 wil6210: fix unsigned cid comparison with >= 0

Signature · 3 lines
https://patchwork.kernel.org/patch/10580739/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches