drivers/net/wireless/ath/wcn36xx/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
KASAN reported a memory allocation issue in wcn->chan_survey
due to incorrect size calculation.
This commit uses kcalloc to allocate memory for wcn->chan_survey,
ensuring proper initialization and preventing the use of uninitialized
values when there are no frames on the channel.
Fixes: 29696e0aa413 ("wcn36xx: Track SNR and RSSI for each RX frame")
Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org>
---
drivers/net/wireless/ath/wcn36xx/main.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index 408776562a7e56da3017aa074396bcd241d62f8c..cd36cab6db75d300f4f6617a6a9e1550f62921c7 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -1590,7 +1590,10 @@ static int wcn36xx_probe(struct platform_device *pdev)
}
n_channels = wcn_band_2ghz.n_channels + wcn_band_5ghz.n_channels;
- wcn->chan_survey = devm_kmalloc(wcn->dev, n_channels, GFP_KERNEL);
+ wcn->chan_survey = devm_kcalloc(wcn->dev,
+ n_channels,
+ sizeof(struct wcn36xx_chan_survey),
+ GFP_KERNEL);
if (!wcn->chan_survey) {
ret = -ENOMEM;
goto out_wq;
---
base-commit: 1ffec08567f426a1c593e038cadc61bdc38cb467
change-id: 20241104-wcn36xx-memory-allocation-803e4e3de9a6
Best regards,
--
Barnabás Czémán <barnabas.czeman@mainlining.org>
On Mon, 04 Nov 2024 21:00:35 +0100, Barnabás Czémán wrote: > KASAN reported a memory allocation issue in wcn->chan_survey > due to incorrect size calculation. > This commit uses kcalloc to allocate memory for wcn->chan_survey, > ensuring proper initialization and preventing the use of uninitialized > values when there are no frames on the channel. > > > [...] Applied, thanks! [1/1] wifi: wcn36xx: fix channel survey memory allocation size commit: 6200d947f050efdba4090dfefd8a01981363d954 Best regards, -- Jeff Johnson <quic_jjohnson@quicinc.com>
On Mon, 4 Nov 2024 at 21:00, Barnabás Czémán <barnabas.czeman@mainlining.org> wrote: > > KASAN reported a memory allocation issue in wcn->chan_survey > due to incorrect size calculation. > This commit uses kcalloc to allocate memory for wcn->chan_survey, > ensuring proper initialization and preventing the use of uninitialized > values when there are no frames on the channel. > > Fixes: 29696e0aa413 ("wcn36xx: Track SNR and RSSI for each RX frame") > Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org> Acked-by: Loic Poulain <loic.poulain@linaro.org>
On 04/11/2024 20:00, Barnabás Czémán wrote: > KASAN reported a memory allocation issue in wcn->chan_survey > due to incorrect size calculation. > This commit uses kcalloc to allocate memory for wcn->chan_survey, > ensuring proper initialization and preventing the use of uninitialized > values when there are no frames on the channel. > > Fixes: 29696e0aa413 ("wcn36xx: Track SNR and RSSI for each RX frame") > Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org> > --- > drivers/net/wireless/ath/wcn36xx/main.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c > index 408776562a7e56da3017aa074396bcd241d62f8c..cd36cab6db75d300f4f6617a6a9e1550f62921c7 100644 > --- a/drivers/net/wireless/ath/wcn36xx/main.c > +++ b/drivers/net/wireless/ath/wcn36xx/main.c > @@ -1590,7 +1590,10 @@ static int wcn36xx_probe(struct platform_device *pdev) > } > > n_channels = wcn_band_2ghz.n_channels + wcn_band_5ghz.n_channels; > - wcn->chan_survey = devm_kmalloc(wcn->dev, n_channels, GFP_KERNEL); > + wcn->chan_survey = devm_kcalloc(wcn->dev, > + n_channels, > + sizeof(struct wcn36xx_chan_survey), > + GFP_KERNEL); > if (!wcn->chan_survey) { > ret = -ENOMEM; > goto out_wq; > > --- > base-commit: 1ffec08567f426a1c593e038cadc61bdc38cb467 > change-id: 20241104-wcn36xx-memory-allocation-803e4e3de9a6 > > Best regards, Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
© 2016 - 2024 Red Hat, Inc.