Skip to content

Commit 0e20450

Browse files
qianfengrongjmberg-intel
authored andcommitted
wifi: mwifiex: Initialize the chan_stats array to zero
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: [email protected] Fixes: bf35443 ("mwifiex: channel statistics support for mwifiex") Suggested-by: Dan Carpenter <[email protected]> Signed-off-by: Qianfeng Rong <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 75575e2 commit 0e20450

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
@@ -4673,8 +4673,9 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter)
46734673
* additional active scan request for hidden SSIDs on passive channels.
46744674
*/
46754675
adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a);
4676-
adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats),
4677-
adapter->num_in_chan_stats));
4676+
adapter->chan_stats = kcalloc(adapter->num_in_chan_stats,
4677+
sizeof(*adapter->chan_stats),
4678+
GFP_KERNEL);
46784679

46794680
if (!adapter->chan_stats)
46804681
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)