Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp744711rdd; Tue, 9 Jan 2024 20:14:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoY8LZ4b2SbyyIKCr6c3uJEhAVsvFJqoL1h3GBetXhsligsFoptlgnVktG2+sf7+ZUW87C X-Received: by 2002:a05:6830:1619:b0:6dc:8bc:43e8 with SMTP id g25-20020a056830161900b006dc08bc43e8mr132374otr.66.1704860089260; Tue, 09 Jan 2024 20:14:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704860089; cv=none; d=google.com; s=arc-20160816; b=CNeuf6SUsaNWTLF6G6Wv4ZpZWqDuRaedMd/qsOYLyxUBGWvZ6j0PCoVZmcqBZu1ojx bJmMMyJFbq8sypjdpCUYa6+5AltNkH/rWtm0CoxU9s37zp3cPQnO5lTEDDgv4XXXBB+J WYduQHpv0ygKLs/yQVHovhJoHaEpFcNuwpucPlPwzXwmcS20kfbIFIFp5ciEAQcTh5sF JpjQgL6X+Hebcd+pKzfhxIfmAaS3X2Frvrg1KIxBIJOSn7RxallYl2+JZZ5GPI4qM3ii SqBydYU3J5BXA9Jp/vhXMV+FdWNtjs8KSoPXo/jPobOhT4oYdBMuoSvzjcgsP2lsWDnE Prqg== 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; bh=xfp2C9+4Jou8ZXRGDWWbSoR3kwdmXG2rFsK02C13wpU=; fh=c/cymCWu+6r6a3ijc/NBW1k8SUtk9GDEDWMtSdCy7J0=; b=q8SiuSWxItR3BB74PBwAWQsXrxKin5fn4aVPPkADvsFdqhVBbuiTrc3BXZslxYOWD9 yjR0YH6Yp3XoSfm4blXFeqE+BDJppPb7wZ+x78wLib0EBTI8AXo9tYDF+HL2aDlMr+/I w2fvpb6Hoa5SgSDLlMd/BKdyppK9j3L+RAVs+DkMpmOxlALH/kp6so3M1ETV/j/Xmy8w tubmPN0aXCjWd+HSU7gy6+rivaNrF4MmVAKAeAa1b7SX4lnJfbn+tsejgBqgn0fmhlth 4CrrKF6H6F4k+DpLj4dyOfngkPGsP5PwtrEq/DNjzdYxANC2VcIJMzS8RCu6nCIR8PVB +Dng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-1646-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1646-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t71-20020a63814a000000b005c701bcfe09si2748692pgd.27.2024.01.09.20.14.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 20:14:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-1646-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-1646-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1646-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 51DE4289A53 for ; Wed, 10 Jan 2024 04:14:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28F9A523C; Wed, 10 Jan 2024 04:14:47 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 092EE5683 for ; Wed, 10 Jan 2024 04:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 112b22bd177d468abdedeb120a1f6baa-20240110 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:d0e863ef-7667-40a7-83ea-f8c4d6d7058c,IP:5,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-10 X-CID-INFO: VERSION:1.1.35,REQID:d0e863ef-7667-40a7-83ea-f8c4d6d7058c,IP:5,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:-10 X-CID-META: VersionHash:5d391d7,CLOUDID:7eb8ff2e-1ab8-4133-9780-81938111c800,B ulkID:24011012122039I1WV0C,BulkQuantity:5,Recheck:0,SF:19|44|66|24|17|102, TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 112b22bd177d468abdedeb120a1f6baa-20240110 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(112.64.161.44)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 749153247; Wed, 10 Jan 2024 12:14:38 +0800 From: Li Lin Mao To: linux-wireless@vger.kernel.org Cc: pkshih@realtek.com, kvalo@kernel.org, Li Lin Mao Subject: [PATCH v2] wifi: rtw89: 8852b: avoid reporting errors by cppcheck Date: Wed, 10 Jan 2024 12:14:31 +0800 Message-Id: <20240110041431.2806052-1-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Due to some reasons in cppcheck, the following issues might be reported: drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: error: Array 'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*], which is out of bounds. [arrayIndexOutOfBounds] iqk_info->iqk_mcc_ch[idx][path] = chan->channel; ^ drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for loop, idx has value 2 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) { ^ drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1414:22: note: Array index out of bounds iqk_info->iqk_mcc_ch[idx][path] = chan->channel; ^ drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: error: Array 'iqk_info->iqk_mcc_ch[2][4]' accessed at index iqk_info->iqk_mcc_ch[2][*], which is out of bounds. [arrayIndexOutOfBounds] idx, path, iqk_info->iqk_mcc_ch[idx][path]); ^ drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1393:2: note: After for loop, idx has value 2 for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) { ^ drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c:1424:38: note: Array index out of bounds idx, path, iqk_info->iqk_mcc_ch[idx][path]); ^ But actually this might be a false alarm. We avoided it in some way. Signed-off-by: Ping-Ke Shih Signed-off-by: Li Lin Mao --- drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c index 259df67836a0..03169287667c 100644 --- a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c +++ b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c @@ -1388,17 +1388,15 @@ static void _iqk_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, u u32 reg_rf18; u32 reg_35c; u8 idx; - u8 get_empty_table = false; for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) { if (iqk_info->iqk_mcc_ch[idx][path] == 0) { - get_empty_table = true; break; } } rtw89_debug(rtwdev, RTW89_DBG_RFK, "[IQK] (1)idx = %x\n", idx); - if (!get_empty_table) { + if (idx >= RTW89_IQK_CHS_NR) { idx = iqk_info->iqk_table_idx[path] + 1; if (idx > 1) idx = 0; -- 2.25.1