2023-07-03 14:30:03

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH] ath9k: use struct_group() to silence static checker warning

We are deliberately copying both ba_high and ba_low so use a struct
group to make that clear. Otherwise static checkers like Smatch and
Clang complain that we are copying beyond the end of the ba_low struct
member.

Signed-off-by: Dan Carpenter <[email protected]>
---
drivers/net/wireless/ath/ath9k/mac.h | 6 ++++--
drivers/net/wireless/ath/ath9k/xmit.c | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index af44b33814dd..f03d792732da 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -115,8 +115,10 @@ struct ath_tx_status {
u8 qid;
u16 desc_id;
u8 tid;
- u32 ba_low;
- u32 ba_high;
+ struct_group(ba,
+ u32 ba_low;
+ u32 ba_high;
+ );
u32 evm0;
u32 evm1;
u32 evm2;
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index f6f2ab7a63ff..42058368e637 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -468,7 +468,7 @@ static void ath_tx_count_frames(struct ath_softc *sc, struct ath_buf *bf,
isaggr = bf_isaggr(bf);
if (isaggr) {
seq_st = ts->ts_seqnum;
- memcpy(ba, &ts->ba_low, WME_BA_BMP_SIZE >> 3);
+ memcpy(ba, &ts->ba, WME_BA_BMP_SIZE >> 3);
}

while (bf) {
@@ -551,7 +551,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
if (isaggr && txok) {
if (ts->ts_flags & ATH9K_TX_BA) {
seq_st = ts->ts_seqnum;
- memcpy(ba, &ts->ba_low, WME_BA_BMP_SIZE >> 3);
+ memcpy(ba, &ts->ba, WME_BA_BMP_SIZE >> 3);
} else {
/*
* AR5416 can become deaf/mute when BA
--
2.39.2



2023-07-03 15:02:09

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] ath9k: use struct_group() to silence static checker warning

On Mon, Jul 3, 2023, at 16:17, Dan Carpenter wrote:
> We are deliberately copying both ba_high and ba_low so use a struct
> group to make that clear. Otherwise static checkers like Smatch and
> Clang complain that we are copying beyond the end of the ba_low struct
> member.
>
> Signed-off-by: Dan Carpenter <[email protected]>

Reviewed-by: Arnd Bergmann <[email protected]>

2023-07-03 17:50:07

by Toke Høiland-Jørgensen

[permalink] [raw]
Subject: Re: [PATCH] ath9k: use struct_group() to silence static checker warning

Dan Carpenter <[email protected]> writes:

> We are deliberately copying both ba_high and ba_low so use a struct
> group to make that clear. Otherwise static checkers like Smatch and
> Clang complain that we are copying beyond the end of the ba_low struct
> member.
>
> Signed-off-by: Dan Carpenter <[email protected]>

Thanks for the fix; however, an identical patch is already queued, here:
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

-Toke