Skip to content

Commit

Permalink
wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802…
Browse files Browse the repository at this point in the history
…_11_scan()

The type of "mwifiex_adapter->nd_info" is "struct cfg80211_wowlan_nd_info",
not "struct cfg80211_wowlan_nd_match".

Use struct_size() to ease the computation of the needed size.

The current code over-allocates some memory, so is safe.
But it wastes 32 bytes.

Fixes: 7d7f07d ("mwifiex: add wowlan net-detect support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/7a6074fb056d2181e058a3cc6048d8155c20aec7.1683371982.git.christophe.jaillet@wanadoo.fr
  • Loading branch information
Christophe JAILLET authored and Kalle Valo committed May 11, 2023
1 parent e2ff118 commit d9aef04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/wireless/marvell/mwifiex/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2187,9 +2187,9 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,

if (nd_config) {
adapter->nd_info =
kzalloc(sizeof(struct cfg80211_wowlan_nd_match) +
sizeof(struct cfg80211_wowlan_nd_match *) *
scan_rsp->number_of_sets, GFP_ATOMIC);
kzalloc(struct_size(adapter->nd_info, matches,
scan_rsp->number_of_sets),
GFP_ATOMIC);

if (adapter->nd_info)
adapter->nd_info->n_matches = scan_rsp->number_of_sets;
Expand Down

0 comments on commit d9aef04

Please sign in to comment.