diff mbox series

rtw89: use flexible array member in rtw89_btc_btf_tlv

Message ID 20230523113241.2772811-1-arnd@kernel.org (mailing list archive)
State Accepted
Commit 47e612268ea02f7d2bcbaa47528698b5be61a8cf
Delegated to: Kalle Valo
Headers show
Series rtw89: use flexible array member in rtw89_btc_btf_tlv | expand

Commit Message

Arnd Bergmann May 23, 2023, 11:32 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

struct rtw89_btc_btf_tlv contains a one-byte member that is intended as a
flexible array:

In function 'fortify_memcpy_chk',
    inlined from '_append_tdma' at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
  583 |                         __write_overflow_field(p_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Make this actually use a flexible array to let the compiler understand.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ping-Ke Shih May 24, 2023, 1:24 a.m. UTC | #1
> -----Original Message-----
> From: Arnd Bergmann <arnd@kernel.org>
> Sent: Tuesday, May 23, 2023 7:33 PM
> To: Ping-Ke Shih <pkshih@realtek.com>; Kalle Valo <kvalo@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>; DeanKu <ku920601@realtek.com>; linux-wireless@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: [PATCH] rtw89: use flexible array member in rtw89_btc_btf_tlv
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> struct rtw89_btc_btf_tlv contains a one-byte member that is intended as a
> flexible array:
> 
> In function 'fortify_memcpy_chk',
>     inlined from '_append_tdma' at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
> include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute
> warning: detected write beyond size of field (1st parameter); maybe use struct_group()?
> [-Werror=attribute-warning]
>   583 |                         __write_overflow_field(p_size_field, size);
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Make this actually use a flexible array to let the compiler understand.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>

> ---
>  drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
> index 3a586a971e8f..bda0e1e99a8c 100644
> --- a/drivers/net/wireless/realtek/rtw89/coex.c
> +++ b/drivers/net/wireless/realtek/rtw89/coex.c
> @@ -206,7 +206,7 @@ static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = {
>  struct rtw89_btc_btf_tlv {
>         u8 type;
>         u8 len;
> -       u8 val[1];
> +       u8 val[];
>  } __packed;
> 
>  enum btc_btf_set_report_en {
> --
> 2.39.2
Gustavo A. R. Silva May 24, 2023, 10:43 a.m. UTC | #2
On 5/23/23 05:32, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> struct rtw89_btc_btf_tlv contains a one-byte member that is intended as a
> flexible array:
> 
> In function 'fortify_memcpy_chk',
>      inlined from '_append_tdma' at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
> include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
>    583 |                         __write_overflow_field(p_size_field, size);
>        |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Make this actually use a flexible array to let the compiler understand.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks!
--
Gustavo

> ---
>   drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
> index 3a586a971e8f..bda0e1e99a8c 100644
> --- a/drivers/net/wireless/realtek/rtw89/coex.c
> +++ b/drivers/net/wireless/realtek/rtw89/coex.c
> @@ -206,7 +206,7 @@ static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = {
>   struct rtw89_btc_btf_tlv {
>   	u8 type;
>   	u8 len;
> -	u8 val[1];
> +	u8 val[];
>   } __packed;
>   
>   enum btc_btf_set_report_en {
Kalle Valo May 25, 2023, 4:14 p.m. UTC | #3
Arnd Bergmann <arnd@kernel.org> wrote:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> struct rtw89_btc_btf_tlv contains a one-byte member that is intended as a
> flexible array:
> 
> In function 'fortify_memcpy_chk',
>     inlined from '_append_tdma' at drivers/net/wireless/realtek/rtw89/coex.c:1579:3:
> include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
>   583 |                         __write_overflow_field(p_size_field, size);
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Make this actually use a flexible array to let the compiler understand.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Patch applied to wireless-next.git, thanks.

47e612268ea0 wifi: rtw89: use flexible array member in rtw89_btc_btf_tlv
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index 3a586a971e8f..bda0e1e99a8c 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -206,7 +206,7 @@  static const struct rtw89_btc_ver rtw89_btc_ver_defs[] = {
 struct rtw89_btc_btf_tlv {
 	u8 type;
 	u8 len;
-	u8 val[1];
+	u8 val[];
 } __packed;
 
 enum btc_btf_set_report_en {