From patchwork Wed Feb 2 07:09:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 12732650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9C2FC433EF for ; Wed, 2 Feb 2022 07:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239816AbiBBHCE (ORCPT ); Wed, 2 Feb 2022 02:02:04 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49598 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239384AbiBBHCD (ORCPT ); Wed, 2 Feb 2022 02:02:03 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2B4A561725; Wed, 2 Feb 2022 07:02:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E623AC004E1; Wed, 2 Feb 2022 07:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643785322; bh=1Q7jHDq8Ep5G9c1wiZDgu8/YIoEi3BDZpHF88CwnPCw=; h=Date:From:To:Cc:Subject:From; b=ZFG/mYt5wvg0M4Hxk9AhiEFaWy9tEksm76vxSYmw7j9mTetnmD4sfp5ZwDsfkcmY+ Ss0J5lrYZanq+jovoF72FR/QfYJ2aEJ9sdAHlbR37D0Bzlt/yOWzPgqOX9WELMnfxx aRcZIF5zQ1ewRyjFoOKqISlIzjlycticar01ZwwIcng4k30Klr7/Dd3YlR4owXyWht PmUSTsc4xr+Bh2uPVxCHVXW99USJFfYZSCvQcPmPRKxJCP/dnZHUp02wyF9Jf2zghD c561zoOZEjJ5RhEN8sryC9YmyksgIDZ0tz40mzTuaKbaSVeer4sDzBpTGj3IZ1sOi6 t7hV5vR17D3XQ== Date: Wed, 2 Feb 2022 01:09:06 -0600 From: "Gustavo A. R. Silva" To: Larry Finger , Phillip Potter , Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH v3][next] staging: r8188eu: Silence out-of-bounds warning in HT_caps_handler() Message-ID: <20220202070906.GA274379@embeddedor> MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Silence the following out-of-bounds warning (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. Reviewed-by: Dan Carpenter Signed-off-by: Gustavo A. R. Silva --- Changes in v3: - Change subject line and changelog text. - Add RB tag. Changes in v2: - Fix subject line. drivers/staging/r8188eu/include/wlan_bssdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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[]; }; /*