ath10k: htt_rx: Fix signedness bug in ath10k_update_per_peer_tx_stats
Subsystems (3)
PATCH 1/1 ath10k: htt_rx: Fix signedness bug in ath10k_update_per_peer_tx_stats
Currently, the error handling for the call to function ath10k_get_legacy_rate_idx() doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.
Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +2 -1
@@ -2753,7 +2753,8 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, struct ath10k_per_peer_tx_stats *peer_stats) {struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; -u8 rate =0 , rate_idx =0 , sgi; +u8 rate =0 , sgi; +s8 rate_idx =0 ;struct rate_info txrate;lockdep_assert_held (&ar->data_lock);
Signature · 1 line
2.7.4
Quoted 8 lines · Gustavo A. R. Silva
Currently, the error handling for the call to function
ath10k_get_legacy_rate_idx()doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
There are more than 127 rates, are you sure this is doing what you want?
Thanks,
Ben
Quoted 23 lines
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
Fixes 0189dbd71cbd ("ath10k: get the legacy rate index to update the txrate table")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/wireless/ath/ath10k/htt_rx.c +2
-1@@ -2753,7 +2753,8 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, struct ath10k_per_peer_tx_stats *peer_stats) {struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; -u8 rate =0 , rate_idx =0 , sgi; +u8 rate =0 , sgi; +s8 rate_idx =0 ;struct rate_info txrate;lockdep_assert_held (&ar->data_lock);
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 7 lines · Ben Greear
Quoted 6 lines · Gustavo A. R. Silva
Currently, the error handling for the call to function
ath10k_get_legacy_rate_idx()doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.
Quoted 6 lines
Quoted 2 lines
Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
There are more than 127 rates, are you sure this is doing what you want?
Based on the following function, rate_idx can only hold values from 0 to 11
static inline int ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate)
{
static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12,
18, 24, 36, 48, 54};
int i;
for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) {
if (rate == legacy_rates[i])
return i;
}
ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate);
return -EINVAL;
}Thanks
--
Gustavo
Quoted 28 lines
Thanks,
BenQuoted 23 lines
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
Fixes 0189dbd71cbd ("ath10k: get the legacy rate index to update the txrate table")Signed-off-by Gustavo A. R. Silva <[email protected]>---
drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/wireless/ath/ath10k/htt_rx.c +2
-1@@ -2753,7 +2753,8 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, struct ath10k_per_peer_tx_stats *peer_stats) { struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; - u8 rate = 0, rate_idx = 0, sgi; + u8 rate = 0, sgi; + s8 rate_idx = 0; struct rate_info txrate; lockdep_assert_held(&ar->data_lock);
Quoted 10 lines · Gustavo A. R. Silva
Quoted 7 lines · Ben Greear
Quoted 6 lines · Gustavo A. R. Silva
Currently, the error handling for the call to function
ath10k_get_legacy_rate_idx()doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
There are more than 127 rates, are you sure this is doing what you want?
Based on the following function,
rate_idxcan only hold values from 0 to 11
... and of course -EINVAL too
Quoted 47 lines
static inline int
ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate){ static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54}; int i; for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) { if (rate == legacy_rates[i]) return i; } ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate); return -EINVAL; }Thanks
--
GustavoQuoted 28 lines
Thanks,
BenQuoted 23 lines
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
Fixes 0189dbd71cbd ("ath10k: get the legacy rate index to update the txrate table")Signed-off-by Gustavo A. R. Silva <gustavo-L1vi/[email protected]>---
drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/wireless/ath/ath10k/htt_rx.c +2
-1@@ -2753,7 +2753,8 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, struct ath10k_per_peer_tx_stats *peer_stats) { struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; - u8 rate = 0, rate_idx = 0, sgi; + u8 rate = 0, sgi; + s8 rate_idx = 0; struct rate_info txrate; lockdep_assert_held(&ar->data_lock);
Quoted 14 lines · Gustavo A. R. Silva
Quoted 13 lines · Gustavo A. R. Silva
Quoted 10 lines · Ben Greear
Quoted 8 lines · Gustavo A. R. Silva
Currently, the error handling for the call to function
ath10k_get_legacy_rate_idx()doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
Quoted 57 lines
Quoted 6 lines
Quoted 3 lines
There are more than 127 rates, are you sure this is doing what you want?
Based on the following function,
rate_idxcan only hold values from 0 to 11... and of course
-EINVALtooQuoted 48 lines
static inline int
ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate){ static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54}; int i; for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) { if (rate == legacy_rates[i]) return i; } ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate); return -EINVAL; }Thanks
--
GustavoQuoted 29 lines
Thanks,
BenQuoted 24 lines
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
Fixes 0189dbd71cbd ("ath10k: get the legacy rate index to update the txrate table")Signed-off-by Gustavo A. R. Silva <[email protected]>---
drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/wireless/ath/ath10k/htt_rx.c +2
-1@@ -2753,7 +2753,8 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar, struct ath10k_per_peer_tx_stats *peer_stats) { struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; - u8 rate = 0, rate_idx = 0, sgi; + u8 rate = 0, sgi; + s8 rate_idx = 0; struct rate_info txrate;
lockdep_assert_held(&ar->data_lock);
I have sent a patch to address this,
https://patchwork.kernel.org/patch/10611943/
Thanks
Anil.
Quoted 5 lines
I have sent a patch to address this,
https://patchwork.kernel.org/patch/10611943/
That's great.
Thanks for letting me know. :)
--
Gustavo
Quoted 6 lines · Gustavo A. R. Silva
Currently, the error handling for the call to function
ath10k_get_legacy_rate_idx()doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.
Quoted 7 lines
Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
Fixes 0189dbd71cbd ("ath10k: get the legacy rate index to update the txrate table")Signed-off-by Gustavo A. R. Silva <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
9d9cdbf3f9ed ath10k: htt_rx: fix signedness bug in ath10k_update_per_peer_tx_stats
Signature · 3 lines
https://patchwork.kernel.org/patch/10628675/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 6 lines · Gustavo A. R. Silva
Currently, the error handling for the call to function
ath10k_get_legacy_rate_idx()doesn't work because *rate_idx* is of type u8 (8 bits, unsigned), which makes it impossible for it to hold a value less than 0.
Quoted 7 lines
Fix this by changing the type of variable *rate_idx* to s8 (8 bits, signed).
Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0")
Fixes 0189dbd71cbd ("ath10k: get the legacy rate index to update the txrate table")Signed-off-by Gustavo A. R. Silva <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
9d9cdbf3f9ed ath10k: htt_rx: fix signedness bug in ath10k_update_per_peer_tx_stats
Signature · 3 lines
https://patchwork.kernel.org/patch/10628675/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 5 lines · Kalle Valo
Patch applied to ath-next branch of ath.git, thanks.
9d9cdbf3f9edath10k:htt_rx: fix signedness bug inath10k_update_per_peer_tx_stats
Thank you, Kalle.
--
Gustavo