Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2540863rdb; Sun, 3 Dec 2023 23:30:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHvLSXOOh2IZTMEM7bDyd1g0rOtuvmhTv70u/6zjR3nS83ySPN/7Uat4/BESeeR8KrCJl+ X-Received: by 2002:a17:90a:4964:b0:286:7c14:6d0a with SMTP id c91-20020a17090a496400b002867c146d0amr2760539pjh.10.1701675035154; Sun, 03 Dec 2023 23:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701675035; cv=none; d=google.com; s=arc-20160816; b=Q6tYskXEpLDkUscte6acW0CDzzjPG7g757qfR+GF0XdvGjxWXCFupy1mLkpbZc+vZq sLNvCq+1mbRCKq5Mtw707yUFw1LxLvd2AytA1nmJMvS5sD78g1Z9li/5Ncr2XHj4Gkyv 1paUGrhKbE0J6mqC8AicKSCRMmCWUMhn5R0/T1bimOOjvW27dZy/wvWaZiLixdMJMv4H fXtQzYAe0iFcBaNrWaaBcsQUTL5IFK52SE8qX115z+csd+U4WcaERVANgxv/O+TVJvmy nc1vxjipwPQztVfIVepzyDwWmb9ohRKr7Y0UZq8p8UgGiSb0Yguq5DMDoV7sPpYZaIjx 93sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=SsvdiMFeXgNuw1aLqpyaAq7NzCejPjii33J/c02sRqI=; fh=odONOS7FpyGbJkxXOTORAO519RkLaLiz6nBCVtVY368=; b=EGvN3/mtNDHRPWShZCuJAT8Om8S8B5MAbxAjkQQ59EsPwrpYrIMZvho++YeACOm5tv PBTEScpyd1U+a97TbNNhcSBvAnp9hBPLnsyXtuFxck57YsSPN0deexx8M0mebHPW6myi PCE94GnFV5PZLfOYvJMsvdw/CirQKBjxqOunM4mNkAwuy+D0TPe5slMBGPM2oVcDFvRc x2GL2Ku8vYQ5i9uB18Sz2nCDiMVs42aMKGXC9hcwhL5jFXC+42bKUd7ACYeirUttZuB7 I2jQGjCH+j5T6DipFAOYna2D/YU2wJQfUb06M/18QY+w/6AVEQtKku9XsjfdMKmosQsw VW5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W8nfxDmR; spf=pass (google.com: domain of linux-wireless+bounces-348-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-348-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e3-20020a63d943000000b005aebc9096d4si7405052pgj.150.2023.12.03.23.30.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 23:30:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-348-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W8nfxDmR; spf=pass (google.com: domain of linux-wireless+bounces-348-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-348-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CB064B208A8 for ; Mon, 4 Dec 2023 07:30:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3076C9449; Mon, 4 Dec 2023 07:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W8nfxDmR" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1019F186C for ; Mon, 4 Dec 2023 07:30:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAFE3C433C7; Mon, 4 Dec 2023 07:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701675026; bh=UXHIbSEXNeT4NOlOwMLwRYUsh1rg0DBD7QbaAh9KxAU=; h=From:To:Cc:Subject:Date:From; b=W8nfxDmRpeEwPLmtg/wG9eP4VA9cp8hQ+6hIXWHSf+UPEzlsebyFvHC6QAwvxwJR8 9iToyOU65x9LDh4uXJooLpqDAgyga7w/tDHVFE48tYOGJ2f6WsM8oOVICgtbZjTnCI fD3Cr5KQQmyBfype4t5lvNALAWm//Y51o38ID/zyfKev9PkYszdbeY2Z5ahmVRsOLX bdmX+EqMY1ucCVmZdJ+jpf3G10J3BZ33xO2irE9uJKQ2WtO50JekjfTlSFeTFr73gT V0favpOb0zVMtJvazYS7dJYg1v/W2r6HklbCBj3R1pa2Fn25Q3kuapp1ULz3qk2lrJ UXpSDWJolgPoA== From: Arnd Bergmann To: Ping-Ke Shih , Kalle Valo , "Gustavo A. R. Silva" Cc: Arnd Bergmann , Ching-Te Ku , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rtw89: avoid stringop-overflow warning Date: Mon, 4 Dec 2023 08:30:13 +0100 Message-Id: <20231204073020.1105416-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann After -Wstringop-overflow got enabled, the rtw89 driver produced two odd warnings with gcc-13: drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_scan_start': drivers/net/wireless/realtek/rtw89/coex.c:5362:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 5362 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from drivers/net/wireless/realtek/rtw89/coex.h:8, from drivers/net/wireless/realtek/rtw89/coex.c:5: drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2 1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */ | ^~~~~~~~~ drivers/net/wireless/realtek/rtw89/coex.c: In function 'rtw89_btc_ntfy_switch_band': drivers/net/wireless/realtek/rtw89/coex.c:5406:50: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 5406 | wl->dbcc_info.scan_band[phy_idx] = band; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ drivers/net/wireless/realtek/rtw89/core.h:1441:12: note: at offset [64, 255] into destination object 'scan_band' of size 2 1441 | u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */ | ^~~~~~~~~ I don't know what happened here, but adding an explicit range check shuts up the output. Fixes: 89741e7e42f6 ("Makefile: Enable -Wstringop-overflow globally") Signed-off-by: Arnd Bergmann --- drivers/net/wireless/realtek/rtw89/coex.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c index b842cd9a86f8..9c0db35d3e13 100644 --- a/drivers/net/wireless/realtek/rtw89/coex.c +++ b/drivers/net/wireless/realtek/rtw89/coex.c @@ -5352,6 +5352,10 @@ void rtw89_btc_ntfy_scan_start(struct rtw89_dev *rtwdev, u8 phy_idx, u8 band) rtw89_debug(rtwdev, RTW89_DBG_BTC, "[BTC], %s(): phy_idx=%d, band=%d\n", __func__, phy_idx, band); + + if (phy_idx >= RTW89_PHY_MAX) + return; + btc->dm.cnt_notify[BTC_NCNT_SCAN_START]++; wl->status.map.scan = true; wl->scan_info.band[phy_idx] = band; @@ -5396,6 +5400,10 @@ void rtw89_btc_ntfy_switch_band(struct rtw89_dev *rtwdev, u8 phy_idx, u8 band) rtw89_debug(rtwdev, RTW89_DBG_BTC, "[BTC], %s(): phy_idx=%d, band=%d\n", __func__, phy_idx, band); + + if (phy_idx >= RTW89_PHY_MAX) + return; + btc->dm.cnt_notify[BTC_NCNT_SWITCH_BAND]++; wl->scan_info.band[phy_idx] = band; -- 2.39.2