All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mt76/mt7915: Fix unsigned compared against zero
@ 2021-06-12 14:35 ` John Wood
  0 siblings, 0 replies; 6+ messages in thread
From: John Wood @ 2021-06-12 14:35 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: John Wood, Kalle Valo, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Shayne Chen, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

The mt7915_dpd_freq_idx() function can return a negative value but this
value is assigned to an unsigned variable named idx. Then, the code
tests if this variable is less than zero. This can never happen with an
unsigned type.

So, change the idx type to a signed one.

Addresses-Coverity-ID: 1484753 ("Unsigned compared against 0")
Fixes: 495184ac91bb8 ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: John Wood <john.wood@gmx.com>
---
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index b3f14ff67c5a..764f25a828fa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3440,8 +3440,9 @@ int mt7915_mcu_apply_tx_dpd(struct mt7915_phy *phy)
 {
 	struct mt7915_dev *dev = phy->dev;
 	struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
-	u16 total = 2, idx, center_freq = chandef->center_freq1;
+	u16 total = 2, center_freq = chandef->center_freq1;
 	u8 *cal = dev->cal, *eep = dev->mt76.eeprom.data;
+	int idx;

 	if (!(eep[MT_EE_DO_PRE_CAL] & MT_EE_WIFI_CAL_DPD))
 		return 0;
--
2.25.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH] mt76/mt7915: Fix unsigned compared against zero
@ 2021-06-12 14:35 ` John Wood
  0 siblings, 0 replies; 6+ messages in thread
From: John Wood @ 2021-06-12 14:35 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: John Wood, Kalle Valo, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Shayne Chen, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

The mt7915_dpd_freq_idx() function can return a negative value but this
value is assigned to an unsigned variable named idx. Then, the code
tests if this variable is less than zero. This can never happen with an
unsigned type.

So, change the idx type to a signed one.

Addresses-Coverity-ID: 1484753 ("Unsigned compared against 0")
Fixes: 495184ac91bb8 ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: John Wood <john.wood@gmx.com>
---
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index b3f14ff67c5a..764f25a828fa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3440,8 +3440,9 @@ int mt7915_mcu_apply_tx_dpd(struct mt7915_phy *phy)
 {
 	struct mt7915_dev *dev = phy->dev;
 	struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
-	u16 total = 2, idx, center_freq = chandef->center_freq1;
+	u16 total = 2, center_freq = chandef->center_freq1;
 	u8 *cal = dev->cal, *eep = dev->mt76.eeprom.data;
+	int idx;

 	if (!(eep[MT_EE_DO_PRE_CAL] & MT_EE_WIFI_CAL_DPD))
 		return 0;
--
2.25.1


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

* [PATCH] mt76/mt7915: Fix unsigned compared against zero
@ 2021-06-12 14:35 ` John Wood
  0 siblings, 0 replies; 6+ messages in thread
From: John Wood @ 2021-06-12 14:35 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: John Wood, Kalle Valo, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Shayne Chen, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

The mt7915_dpd_freq_idx() function can return a negative value but this
value is assigned to an unsigned variable named idx. Then, the code
tests if this variable is less than zero. This can never happen with an
unsigned type.

So, change the idx type to a signed one.

Addresses-Coverity-ID: 1484753 ("Unsigned compared against 0")
Fixes: 495184ac91bb8 ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: John Wood <john.wood@gmx.com>
---
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index b3f14ff67c5a..764f25a828fa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3440,8 +3440,9 @@ int mt7915_mcu_apply_tx_dpd(struct mt7915_phy *phy)
 {
 	struct mt7915_dev *dev = phy->dev;
 	struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
-	u16 total = 2, idx, center_freq = chandef->center_freq1;
+	u16 total = 2, center_freq = chandef->center_freq1;
 	u8 *cal = dev->cal, *eep = dev->mt76.eeprom.data;
+	int idx;

 	if (!(eep[MT_EE_DO_PRE_CAL] & MT_EE_WIFI_CAL_DPD))
 		return 0;
--
2.25.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] 6+ messages in thread

* Re: [PATCH] mt76/mt7915: Fix unsigned compared against zero
  2021-06-12 14:35 ` John Wood
  (?)
@ 2021-06-26 14:30   ` John Wood
  -1 siblings, 0 replies; 6+ messages in thread
From: John Wood @ 2021-06-26 14:30 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: John Wood, Kalle Valo, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Shayne Chen, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

On Sat, Jun 12, 2021 at 04:35:05PM +0200, John Wood wrote:
> The mt7915_dpd_freq_idx() function can return a negative value but this
> value is assigned to an unsigned variable named idx. Then, the code
> tests if this variable is less than zero. This can never happen with an
> unsigned type.
>
> So, change the idx type to a signed one.
>
> Addresses-Coverity-ID: 1484753 ("Unsigned compared against 0")
> Fixes: 495184ac91bb8 ("mt76: mt7915: add support for applying pre-calibration data")

Has anyone had time to review this patch?. Any comment on this?

Thanks,
John Wood

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

* Re: [PATCH] mt76/mt7915: Fix unsigned compared against zero
@ 2021-06-26 14:30   ` John Wood
  0 siblings, 0 replies; 6+ messages in thread
From: John Wood @ 2021-06-26 14:30 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: John Wood, Kalle Valo, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Shayne Chen, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

On Sat, Jun 12, 2021 at 04:35:05PM +0200, John Wood wrote:
> The mt7915_dpd_freq_idx() function can return a negative value but this
> value is assigned to an unsigned variable named idx. Then, the code
> tests if this variable is less than zero. This can never happen with an
> unsigned type.
>
> So, change the idx type to a signed one.
>
> Addresses-Coverity-ID: 1484753 ("Unsigned compared against 0")
> Fixes: 495184ac91bb8 ("mt76: mt7915: add support for applying pre-calibration data")

Has anyone had time to review this patch?. Any comment on this?

Thanks,
John Wood

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] mt76/mt7915: Fix unsigned compared against zero
@ 2021-06-26 14:30   ` John Wood
  0 siblings, 0 replies; 6+ messages in thread
From: John Wood @ 2021-06-26 14:30 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
  Cc: John Wood, Kalle Valo, David S. Miller, Jakub Kicinski,
	Matthias Brugger, Shayne Chen, linux-wireless, netdev,
	linux-arm-kernel, linux-mediatek, linux-kernel

On Sat, Jun 12, 2021 at 04:35:05PM +0200, John Wood wrote:
> The mt7915_dpd_freq_idx() function can return a negative value but this
> value is assigned to an unsigned variable named idx. Then, the code
> tests if this variable is less than zero. This can never happen with an
> unsigned type.
>
> So, change the idx type to a signed one.
>
> Addresses-Coverity-ID: 1484753 ("Unsigned compared against 0")
> Fixes: 495184ac91bb8 ("mt76: mt7915: add support for applying pre-calibration data")

Has anyone had time to review this patch?. Any comment on this?

Thanks,
John Wood

_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2021-06-26 18:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-12 14:35 [PATCH] mt76/mt7915: Fix unsigned compared against zero John Wood
2021-06-12 14:35 ` John Wood
2021-06-12 14:35 ` John Wood
2021-06-26 14:30 ` John Wood
2021-06-26 14:30   ` John Wood
2021-06-26 14:30   ` John Wood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.