From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (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 7491A315D46 for ; Mon, 22 Jun 2026 16:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782145508; cv=none; b=NEquSkeCVkV7G1n7kLPho9ZJ1afCbUhkub4DdlAvtO70n8igX9arrAuX+/ibbvjLbe0zurUuo2HPPUCiTmOR6dIzFPgzDlWbvmWrpkd3lDtd3M/fyfJkfCA8VpwKI3p8ArFGkFZUHuN+dGNHK7DNSqiHEmFCdGV9Cm+smNQ+/b4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782145508; c=relaxed/simple; bh=kT23+lxjnde8FvcYO6qS/pTthbTdy7e/c6VMWoHgPx0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Kkz86uzvnq4gPGkIa+WYowXLI7dAwFTRNHdvbV06N4EvcHosw5FoNeiUrDGF+hu+FlWDUYNOR9fRSzGgHDZD8Fb9oyKlCHMU7YCadAL37yEZul9BnTNz9jG5IBuSrDKklP/g7x/kh4pnnIst+rqpmiB4KFvFTLEExYV1LO2YCX4= 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=gWQmbEGY; arc=none smtp.client-ip=209.85.221.65 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="gWQmbEGY" Received: by mail-wr1-f65.google.com with SMTP id ffacd0b85a97d-461edb387ddso423697f8f.3 for ; Mon, 22 Jun 2026 09:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782145506; x=1782750306; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=W0xzwaD3n16ABP1iHhHW1UsbKHqxtIHiJIXNMhDpIZk=; b=gWQmbEGYwH28EyrEHmBkKlSX/vusSERptO7b1w16YlBiTXivXPKDV0tc1xCAELJINj 07Yz3uPwptlIRCkA8xCQKFxwWUlweradArMyV7c+lG7vuBF6iAfzU31zWoCrSRSc75kz HGMT40+8FmcFqIpZPzCq+DKNe3vwYldoT8Xz2fGrvntMXPtWLSfwzooabR/66TTWtPTf sTRyOZFVuubQrIwzzy7frqt3wYAgZ+Ws/z7Mh1LqQaAxsCMgL2Lb03f9AhDjaPVjb3Pf dw2YanpfsyNql45PSSt2mbx5yp0sYitPYpN9vykVFCQdBHfLVfAFbNRCNP+/aqYm5Pc7 3Klg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782145506; x=1782750306; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=W0xzwaD3n16ABP1iHhHW1UsbKHqxtIHiJIXNMhDpIZk=; b=VLeeEEXl38cj0Ks/KGjEPH2gWAgQgzmXmlpYWqJpf9+skiOyTNmeZ1QlM11shMVGCJ nCzDW0hejmDFugtpUVG7/WEMi4QqscDHm+8hLnxwTP78fMxQT7KVgM6RrUYk/5pe1396 KUOboP6V25t60pvHZ1F+c+fGUUPU0o7iGFPC8vDg/2QdmLwZHV+oi8SX0DItu8A3vDap IHU/tRZU5IcIj4tg9ECj7npJW1bxfUl0ozROrMeRFaR55e4RuFIZolg/yZUD+nRtQ96e 68hhDLU5sYzTwlE/LhL7rIulhcqRx+WjHZei/PrHJZ4KF28LM9stMr3GdVFHM3cc+YJg zMnw== X-Forwarded-Encrypted: i=1; AHgh+Ro4mlq74FJu7mk4awchKe1+a3avRTKw1iZRYPxkNfBJI6m2rxEa0RV+o5N0o49gFrPY4svTtyvBzYU3Kn8=@vger.kernel.org X-Gm-Message-State: AOJu0YwIoYhsmVcFMYMtxuFbDhEQJB7CxWLOxrL2GsOnzlfAYpjNwa2z TJ+uYWvbjD5ArlO6J2nscpVEL9mheBXlxjUWX1S3BCs4jq6ygx3/S0czCSw81q1TerhYLA== X-Gm-Gg: AfdE7cmb147tQ3IAPHzK2uJ6GZCpKnYkYjkeMOBHQm8LaJ+sW+du0dsjml69/bxRWiB giHBe4zTobtstfZz/WHHEoJ8QlGiT980yL3v81tuuAwOPFSDr21Z5U/5bpxk3os//xH7tFQkjYY MAV0vY7LN+Xv+svZ4dV5hHZGelNvS1fgDnkkVO0k+AVT+SiPH0bZuZUzV14E79MbhzNaJur6D1B DQ1/KCYTVyiQIoqcF56tpW7QauN/BR3XPEh7WZeDQmEGBvElVuRuhBYSBydV4ZenYzvpLnvVCyq aXw71QpVh88uPekaIEUlQX5NKhMdX1D5GUC+ipKnnUV0/udZ3W+FGoZMKOIcrlJefIuj0pb3cqq 7lDFEYHk/azHCfTLFs6NH1nyZ96U78C/8lxAhBkfv6vUBfhB4mPtzA6X9+ajrOKYVYP9snd3bnP qTnwxyVk43SQ== X-Received: by 2002:a05:6000:41cb:b0:46a:6474:83a8 with SMTP id ffacd0b85a97d-46a647488b9mr917641f8f.40.1782145505705; Mon, 22 Jun 2026 09:25:05 -0700 (PDT) Received: from fedora ([212.253.214.17]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46666c579d4sm28551010f8f.28.2026.06.22.09.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 09:25:05 -0700 (PDT) From: Serhat Kumral To: linux-staging@lists.linux.dev Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, lgs201920130244@gmail.com, error27@gmail.com, Serhat Kumral , Dan Carpenter Subject: [PATCH v2] staging: rtl8723bs: simplify rtw_spt_band_alloc Date: Mon, 22 Jun 2026 19:09:47 +0300 Message-ID: <20260622160947.7970-1-serhatkumral1@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The function only supports NL80211_BAND_2GHZ and falls through to exit for any other band. Replace the n_channels and n_bitrates local variables with the compile-time constants RTW_2G_CHANNELS_NUM and RTW_G_RATES_NUM directly. Use simple addition in kzalloc() instead of chained size_add() calls, since the sizes are derived from compile-time constants and cannot overflow. Replace the intermediate alloc_sz variable accordingly. Remove the redundant second band check before the init calls, as the early exit at the top of the function guarantees that only the 2GHz case can reach that point. No functional change intended. Suggested-by: Dan Carpenter Signed-off-by: Serhat Kumral --- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 1484336d7..dfc44ebb7 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -110,33 +110,26 @@ 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 channels_sz, bitrate_size; - if (band == NL80211_BAND_2GHZ) { - n_channels = RTW_2G_CHANNELS_NUM; - n_bitrates = RTW_G_RATES_NUM; - } else { + if (band != NL80211_BAND_2GHZ) goto exit; - } - 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, array_size(n_bitrates, sizeof(struct ieee80211_rate))); - spt_band = kzalloc(alloc_sz, GFP_KERNEL); + 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); if (!spt_band) goto exit; - spt_band->channels = (struct ieee80211_channel *)(((u8 *)spt_band) + sizeof(struct ieee80211_supported_band)); - spt_band->bitrates = (struct ieee80211_rate *)(((u8 *)spt_band->channels) + sizeof(struct ieee80211_channel) * n_channels); + spt_band->channels = (void *)spt_band + sizeof(*spt_band); + spt_band->bitrates = (void *)spt_band + sizeof(*spt_band) + channels_sz; spt_band->band = band; - spt_band->n_channels = n_channels; - spt_band->n_bitrates = n_bitrates; + spt_band->n_channels = RTW_2G_CHANNELS_NUM; + spt_band->n_bitrates = RTW_G_RATES_NUM; - if (band == NL80211_BAND_2GHZ) { - rtw_2g_channels_init(spt_band->channels); - rtw_2g_rates_init(spt_band->bitrates); - } + rtw_2g_channels_init(spt_band->channels); + rtw_2g_rates_init(spt_band->bitrates); /* spt_band.ht_cap */ -- 2.54.0