From: Greg KH <gregkh@linuxfoundation.org>
To: Joshua David Crofts <joshua.crofts1@gmail.com>
Cc: grondon@gmail.com, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: Use array_size() in rtw_spt_band_alloc
Date: Wed, 1 Apr 2026 20:15:51 +0200 [thread overview]
Message-ID: <2026040114-evident-groove-c44e@gregkh> (raw)
In-Reply-To: <20260401173917.2946-1-joshua.crofts1@gmail.com>
On Wed, Apr 01, 2026 at 07:39:17PM +0200, Joshua David Crofts wrote:
> Replaced raw multiplication with array_size() macro to prevent
> integer overflows. Found using Coccinelle.
>
> Signed-off-by: Joshua David Crofts <joshua.crofts1@gmail.com>
> ---
> drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index 098456e97..7f0ca5a5e 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> @@ -128,7 +128,8 @@ static struct ieee80211_supported_band *rtw_spt_band_alloc(
> 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->bitrates = (struct ieee80211_rate *)(((u8 *)spt_band->channels) +
> + array_size(n_channels, sizeof(struct ieee80211_channel)));
Can this ever overflow? Who controls n_channels, and why isn't it
bounds check before this? Also, this is just getting a pointer to a
structure, it's not overflowing a size of an allocation.
thanks,
greg k-h
next prev parent reply other threads:[~2026-04-01 18:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 17:39 [PATCH] staging: rtl8723bs: Use array_size() in rtw_spt_band_alloc Joshua David Crofts
2026-04-01 18:15 ` Greg KH [this message]
2026-04-01 20:52 ` Joshua Crofts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026040114-evident-groove-c44e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=grondon@gmail.com \
--cc=joshua.crofts1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox