diff mbox series

[next] staging: r8188eu: Fix out-of-bounds error in

Message ID 20220202052741.GA238470@embeddedor (mailing list archive)
State Mainlined
Commit b47f6db34c296343a22c9db4ebdcc51d92301dbe
Headers show
Series [next] staging: r8188eu: Fix out-of-bounds error in | expand

Commit Message

Gustavo A. R. Silva Feb. 2, 2022, 5:27 a.m. UTC
HT_caps_handler()
Reply-To: 

Fix the following out-of-bounds error (caught with -Warray-bounds=2):

drivers/staging/r8188eu/core/rtw_wlan_util.c: In function ‘HT_caps_handler’:
drivers/staging/r8188eu/core/rtw_wlan_util.c:719:54: error: array subscript 2 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} [-Werror=array-bounds]
  719 |                                             pIE->data[i] & 0x3);
      |                                             ~~~~~~~~~^~~
./include/linux/minmax.h:32:39: note: in definition of macro ‘__cmp_once’
   32 |                 typeof(y) unique_y = (y);               \
      |                                       ^
./include/linux/minmax.h:45:25: note: in expansion of macro ‘__careful_cmp’
   45 | #define min(x, y)       __careful_cmp(x, y, <)
      |                         ^~~~~~~~~~~~~
drivers/staging/r8188eu/core/rtw_wlan_util.c:718:41: note: in expansion of macro ‘min’
  718 |                         max_AMPDU_len = min(pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3,
      |                                         ^~~
In file included from drivers/staging/r8188eu/core/../include/drv_types.h:16,
                 from drivers/staging/r8188eu/core/rtw_wlan_util.c:7:
drivers/staging/r8188eu/core/../include/wlan_bssdef.h:64:13: note: while referencing ‘data’
   64 |         u8  data[1];
      |             ^~~~

by transforming one-element array into a flexible-array member in
struct ndis_802_11_var_ie

This is part of the ongoing efforts to globally enable -Warray-bounds.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/staging/r8188eu/include/wlan_bssdef.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Carpenter Feb. 2, 2022, 6:47 a.m. UTC | #1
Please don't put "Fix out-of-bounds error" when it's not a bug.  Change
"Fix" to "Silence" and "error" to "warning".  Or just say:
staging: r8188eu: Clean up flex array usage ndis_802_11_var_ie

On Tue, Feb 01, 2022 at 11:27:41PM -0600, Gustavo A. R. Silva wrote:
> HT_caps_handler()
> Reply-To: 

Your email headers got messed up.

Otherwise it's fine.  I guess to me I would prefer just one line of
sample error message instead of the complete one pager.  Please resend
with fixed email headers and add my tag.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h
index 99ca097b8edd..9d1c9e763287 100644
--- a/drivers/staging/r8188eu/include/wlan_bssdef.h
+++ b/drivers/staging/r8188eu/include/wlan_bssdef.h
@@ -61,7 +61,7 @@  struct ndis_802_11_fixed_ie {
 struct ndis_802_11_var_ie {
 	u8  ElementID;
 	u8  Length;
-	u8  data[1];
+	u8  data[];
 };
 
 /*