From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ADDB390CAC for ; Mon, 22 Jun 2026 09:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782120048; cv=none; b=itk3H6Wsw58z6hfb51WdyQymCZevS76vMOzzI/s3wqYYluJi+3OZaXF7ZzMxNXYEhnDgTIDGh3LsLCWasTAeYHfb1ZO1HFLVYNW/l07UoSvW4kjfMhkiDl0Zm5+8+NO7StT4PsrTnBeGvjMNmCS5HteggOxMCbJaMa2l4XxMUIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782120048; c=relaxed/simple; bh=Wx9f8iOA6FJPHFR2QcjjZ5qqLADcQhk0Ao2uL+Gl7vo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GgUg2SyXMfKaSm2ezjDI0ohetaqxt6wVMKqlXUWl0xvdXiFJwt8vTjBNWx13rPCJRHw6HE3GZLQHmXKGM6yQN3G6ycb/CkQaemdQV+IaB3yv6ZnGvgyvaI8pd7Rms0g01xYt3X8dcCimNKKL/gH3jc066VsD+R9iPTjFEfjlfhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=et9/vZLJ; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="et9/vZLJ" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c0b97e268f3so336746666b.1 for ; Mon, 22 Jun 2026 02:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782120040; x=1782724840; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=C1qxJTCBnKFJDEPnrv8MjfbwGEomhkttMVcfr8ENwSY=; b=et9/vZLJcPB/2hb02YDb8TsQyxx3NaTP/vdkiQ9o8bF6IBMUfnKMPydM0DmIer4Q4V G+yLHLIFJhjycxCfSPJqlBBcXrSjOe0lSahxGURJ9Lu5vy2/qBdtDcQ/fFg6QB0qRlWo 0lBBe4q8UEHp6lEvJtnoz0cvBh8+3g+JDhdJEXmsJSIMNE8kuk1tVazsBzDC4FkCitGI 2LqcrUU3hwSjBlzWVByvVU+d1uFx37eg4MtnS27s88Tupjte78b0+4GiYbUqUkg7fanZ X8uY+g3KcNZfOSvIkaH0YBWyslbyJM8e7XzoZhFUFj/41Sf0SJ4cQyLm3eFIIl7N10F/ q8aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782120040; x=1782724840; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C1qxJTCBnKFJDEPnrv8MjfbwGEomhkttMVcfr8ENwSY=; b=Zzdjvi/vV1lXZPzs4UKfsAcp4Nn6zGWamIrz2dPGe8m7nq1nIc2fy63MSKFmcyGSsd CRDvyatNc3hnJOzUWnKZ/BTDKA2NS+GM05CsMwFIby+6a1J5khJmTL3UmfgTJNx9yofF SsBN6xCPs54CzH9Rpgj+HMrCuUIzzaIrmkJ4fjTYjo4KROTaFn9IT1pAV3mja/27WoDQ oTGH9sD7UbnIz/KU8nxUapVrdoEGTG03/83/jAt8yxNxCx3cgtPo4KY6AnJAvTp0kPJp n7jkVOSobjHDeFbMtgqWuj6SUImrAnkA+EI49HGk0Ma/TzY8wefcHNZ9ZR+/M3h5zmWR 6Xow== X-Forwarded-Encrypted: i=1; AFNElJ9h8W7bWdvwXyUqik+A/C0udxl0kJy9osOFBVEZHtbKAn53W5M9Q8Q5nTMteirg0GZC7NZ23g7oMK4uj58=@vger.kernel.org X-Gm-Message-State: AOJu0YzC9B5Iojfnj4OTkOoBIu12jBSoGWrkdqSRzGCJo8W1PueNzqbX 9SGhhC1W/r70mHZ0nMv3rtOkgddkEDcq/n5jwhBya1AyZH7GELCgJ2fb X-Gm-Gg: AfdE7cmGWjcbl0ng/y5eDG4MH4rcGAVAandktP+neJLnQVvJSx7Ic0RhrFUYjaYeaYc rHpB07mlFW/rtqPRMXtF728FUiKjotSWMnuGER1grRo9ksBtn+3BfiO1TCJqv326i9jnYbQMf18 S4zaW0O+zr4LoG4oEela54MJBJ1/Y6psIsxb7gl7nRVgNLhljoDA64OBn2ZNPsVrHJYWgOyqP2j IL1Hw4dPjb4KPKNpSoKbT2sgDTRc3Fetc1CoDx852gLAjiVbsm1CizBOlI2u/BvvpZzfe1gg/5I pKSBAsFBcBaAmclogbBtypnYrzoMnsorxMQpkyQJWML0/yN9IWzd8EpAenUIPUDDMQ8ue4sXVmz 6EC2IKKjxRRZBvrsVUAAFCWO1lptU1IfmRm5Al54wF1Ut7pY++kgUcDM5N40pN/KuaIEqzOxPLG Qc6qqe2saR X-Received: by 2002:a17:907:3f1f:b0:c0d:ab45:a070 with SMTP id a640c23a62f3a-c0dab45a33cmr261113466b.35.1782120040372; Mon, 22 Jun 2026 02:20:40 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6977b82fa67sm3040433a12.4.2026.06.22.02.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 02:20:38 -0700 (PDT) Date: Mon, 22 Jun 2026 12:20:34 +0300 From: Dan Carpenter To: Serhat Kumral Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: rtl8723bs: avoid duplicate size computation in rtw_spt_band_alloc Message-ID: References: <20260621133301.13855-1-serhatkumral1@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260621133301.13855-1-serhatkumral1@gmail.com> On Sun, Jun 21, 2026 at 04:33:01PM +0300, Serhat Kumral wrote: > Introduce a local variable to store the channel array size and reuse it > for both the allocation and the bitrates pointer offset, replacing a > redundant open-coded multiplication with the same array_size() result. > > Resolves the Coccinelle warning: > WARNING: array_size is already used (line 124) to compute the same size > > Signed-off-by: Serhat Kumral > --- > drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > index 1484336d7..2e65788ee 100644 > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > @@ -111,7 +111,7 @@ static struct ieee80211_supported_band *rtw_spt_band_alloc( > { > struct ieee80211_supported_band *spt_band = NULL; > int n_channels, n_bitrates; > - size_t alloc_sz; > + size_t alloc_sz, channels_sz; > > if (band == NL80211_BAND_2GHZ) { > n_channels = RTW_2G_CHANNELS_NUM; > @@ -120,15 +120,16 @@ static struct ieee80211_supported_band *rtw_spt_band_alloc( > goto exit; > } > > + channels_sz = array_size(n_channels, sizeof(struct ieee80211_channel)); > alloc_sz = sizeof(*spt_band); > - alloc_sz = size_add(alloc_sz, array_size(n_channels, sizeof(struct ieee80211_channel))); > + alloc_sz = size_add(alloc_sz, channels_sz); > alloc_sz = size_add(alloc_sz, array_size(n_bitrates, sizeof(struct ieee80211_rate))); > spt_band = kzalloc(alloc_sz, GFP_KERNEL); This is still a mess. First of all these size values are constant so the layers of indirection are unnecessary. Pretending they are variable makes code auditors have to check for integer overflows so it wastes valuable time and makes the whole kernel less secure. channels_sz = array_size(RTW_2G_CHANNELS_NUM, sizeof(struct ieee80211_channel)); bitrate_size = array_size(RTW_G_RATES_NUM, sizeof(struct ieee80211_rate)); spt_band = kzalloc(sizeof(*spt_band) + channels_sz + bitrate_size, GFP_KERNEL); spt_band->channels = (void *)spt_band + sizeof(*spt_band); spt_band->bitrates = (void *)spt_band + sizeof(*spt_band) + channels_sz; regards, dan carpenter