netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wireless] mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()
@ 2023-05-06 13:53 Christophe JAILLET
  2023-05-06 16:06 ` Simon Horman
  2023-05-11 13:18 ` [wireless] wifi: " Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-05-06 13:53 UTC (permalink / raw)
  To: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam, Xinming Hu,
	Kalle Valo, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, chunfan chen
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Xinming Hu,
	Amitkumar Karwar, linux-wireless, netdev

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: 7d7f07d8c5d3 ("mwifiex: add wowlan net-detect support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/wireless/marvell/mwifiex/scan.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index ac8001c84293..dd73ade4ddf1 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH wireless] mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()
  2023-05-06 13:53 [PATCH wireless] mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan() Christophe JAILLET
@ 2023-05-06 16:06 ` Simon Horman
  2023-05-11 13:18 ` [wireless] wifi: " Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-05-06 16:06 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam, Xinming Hu,
	Kalle Valo, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, chunfan chen, linux-kernel, kernel-janitors,
	Xinming Hu, Amitkumar Karwar, linux-wireless, netdev

On Sat, May 06, 2023 at 03:53:15PM +0200, Christophe JAILLET wrote:
> 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: 7d7f07d8c5d3 ("mwifiex: add wowlan net-detect support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [wireless] wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()
  2023-05-06 13:53 [PATCH wireless] mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan() Christophe JAILLET
  2023-05-06 16:06 ` Simon Horman
@ 2023-05-11 13:18 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2023-05-11 13:18 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam, Xinming Hu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	chunfan chen, linux-kernel, kernel-janitors, Christophe JAILLET,
	Xinming Hu, Amitkumar Karwar, linux-wireless, netdev

Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> 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: 7d7f07d8c5d3 ("mwifiex: add wowlan net-detect support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>

Patch applied to wireless-next.git, thanks.

d9aef04fcfa8 wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/7a6074fb056d2181e058a3cc6048d8155c20aec7.1683371982.git.christophe.jaillet@wanadoo.fr/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-11 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-06 13:53 [PATCH wireless] mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan() Christophe JAILLET
2023-05-06 16:06 ` Simon Horman
2023-05-11 13:18 ` [wireless] wifi: " Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).