linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] mt76: fix less than zero check on a u8 variable
@ 2019-05-05 21:31 Colin King
  2019-05-11 13:31 ` Felix Fietkau
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-05-05 21:31 UTC (permalink / raw)
  To: Felix Fietkau, Roy Luo, Kalle Valo, David S . Miller,
	Matthias Brugger, linux-wireless, netdev, linux-arm-kernel,
	linux-mediatek
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The signed return from the call to get_omac_idx is being assigned to the
u8 variable mac_idx and then checked for a negative error condition
which is always going to be false. Fix this by assigning the return to
the int variable ret and checking this instead.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/wireless/mediatek/mt76/mt7615/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
index 80e6b211f60b..460d90d5ed6d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
@@ -77,11 +77,12 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
 		goto out;
 	}
 
-	mvif->omac_idx = get_omac_idx(vif->type, dev->omac_mask);
-	if (mvif->omac_idx < 0) {
+	ret = get_omac_idx(vif->type, dev->omac_mask);
+	if (ret < 0) {
 		ret = -ENOSPC;
 		goto out;
 	}
+	mvif->omac_idx = ret;
 
 	/* TODO: DBDC support. Use band 0 and wmm 0 for now */
 	mvif->band_idx = 0;
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] mt76: fix less than zero check on a u8 variable
  2019-05-05 21:31 [PATCH][next] mt76: fix less than zero check on a u8 variable Colin King
@ 2019-05-11 13:31 ` Felix Fietkau
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Fietkau @ 2019-05-11 13:31 UTC (permalink / raw)
  To: Colin King, Roy Luo, Kalle Valo, David S . Miller,
	Matthias Brugger, linux-wireless, netdev, linux-arm-kernel,
	linux-mediatek
  Cc: kernel-janitors, linux-kernel

On 2019-05-05 23:31, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The signed return from the call to get_omac_idx is being assigned to the
> u8 variable mac_idx and then checked for a negative error condition
> which is always going to be false. Fix this by assigning the return to
> the int variable ret and checking this instead.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Already fixed by a similar patch by Dan Carpenter.

- Felix

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-11 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-05 21:31 [PATCH][next] mt76: fix less than zero check on a u8 variable Colin King
2019-05-11 13:31 ` Felix Fietkau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).