Skip to content

Commit 5285b70

Browse files
qianfengronggregkh
authored andcommitted
wifi: mwifiex: Initialize the chan_stats array to zero
commit 0e20450 upstream. The adapter->chan_stats[] array is initialized in mwifiex_init_channel_scan_gap() with vmalloc(), which doesn't zero out memory. The array is filled in mwifiex_update_chan_statistics() and then the user can query the data in mwifiex_cfg80211_dump_survey(). There are two potential issues here. What if the user calls mwifiex_cfg80211_dump_survey() before the data has been filled in. Also the mwifiex_update_chan_statistics() function doesn't necessarily initialize the whole array. Since the array was not initialized at the start that could result in an information leak. Also this array is pretty small. It's a maximum of 900 bytes so it's more appropriate to use kcalloc() instead vmalloc(). Cc: stable@vger.kernel.org Fixes: bf35443 ("mwifiex: channel statistics support for mwifiex") Suggested-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://patch.msgid.link/20250815023055.477719-1-rongqianfeng@vivo.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2f2a09e commit 5285b70

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/net/wireless/marvell/mwifiex/cfg80211.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4668,8 +4668,9 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter)
46684668
* additional active scan request for hidden SSIDs on passive channels.
46694669
*/
46704670
adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a);
4671-
adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats),
4672-
adapter->num_in_chan_stats));
4671+
adapter->chan_stats = kcalloc(adapter->num_in_chan_stats,
4672+
sizeof(*adapter->chan_stats),
4673+
GFP_KERNEL);
46734674

46744675
if (!adapter->chan_stats)
46754676
return -ENOMEM;

drivers/net/wireless/marvell/mwifiex/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context)
642642
goto done;
643643

644644
err_add_intf:
645-
vfree(adapter->chan_stats);
645+
kfree(adapter->chan_stats);
646646
err_init_chan_scan:
647647
wiphy_unregister(adapter->wiphy);
648648
wiphy_free(adapter->wiphy);
@@ -1485,7 +1485,7 @@ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter)
14851485
wiphy_free(adapter->wiphy);
14861486
adapter->wiphy = NULL;
14871487

1488-
vfree(adapter->chan_stats);
1488+
kfree(adapter->chan_stats);
14891489
mwifiex_free_cmd_buffers(adapter);
14901490
}
14911491

0 commit comments

Comments
 (0)