mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix memory leak in brcmf_get_module_param
@ 2025-03-30  9:35 Abdun Nihaal
  2025-03-30 10:09 ` Arend Van Spriel
  2025-03-30 11:33 ` Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: Abdun Nihaal @ 2025-03-30  9:35 UTC (permalink / raw)
  To: arend.vanspriel
  Cc: kvalo, jeff.johnson, abdun.nihaal, toke, jacobe.zang,
	u.kleine-koenig, megi, sebastian.reichel, saikrishnag,
	linux-wireless, brcm80211, brcm80211-dev-list.pdl, linux-kernel

The memory allocated for settings is not freed when brcmf_of_probe
fails. Fix that by freeing settings before returning in error path.

Fixes: 0ff0843310b7 ("wifi: brcmfmac: Add optional lpo clock enable support")
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index cfcf01eb0daa..f26e4679e4ff 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -561,8 +561,10 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
 	if (!found) {
 		/* No platform data for this device, try OF and DMI data */
 		brcmf_dmi_probe(settings, chip, chiprev);
-		if (brcmf_of_probe(dev, bus_type, settings) == -EPROBE_DEFER)
+		if (brcmf_of_probe(dev, bus_type, settings) == -EPROBE_DEFER) {
+			kfree(settings);
 			return ERR_PTR(-EPROBE_DEFER);
+		}
 		brcmf_acpi_probe(dev, bus_type, settings);
 	}
 	return settings;
-- 
2.47.2


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

* Re: [PATCH] Fix memory leak in brcmf_get_module_param
  2025-03-30  9:35 [PATCH] Fix memory leak in brcmf_get_module_param Abdun Nihaal
@ 2025-03-30 10:09 ` Arend Van Spriel
  2025-03-30 10:13   ` Arend Van Spriel
  2025-03-30 11:33 ` Markus Elfring
  1 sibling, 1 reply; 4+ messages in thread
From: Arend Van Spriel @ 2025-03-30 10:09 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: kvalo, jeff.johnson, toke, jacobe.zang, u.kleine-koenig, megi,
	sebastian.reichel, saikrishnag, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl, linux-kernel

On March 30, 2025 11:35:41 AM Abdun Nihaal <abdun.nihaal@gmail.com> wrote:

> The memory allocated for settings is not freed when brcmf_of_probe
> fails. Fix that by freeing settings before returning in error path.
>
> Fixes: 0ff0843310b7 ("wifi: brcmfmac: Add optional lpo clock enable support")

Good catch. Thanks for the fix.

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)



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

* Re: [PATCH] Fix memory leak in brcmf_get_module_param
  2025-03-30 10:09 ` Arend Van Spriel
@ 2025-03-30 10:13   ` Arend Van Spriel
  0 siblings, 0 replies; 4+ messages in thread
From: Arend Van Spriel @ 2025-03-30 10:13 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: kvalo, jeff.johnson, toke, jacobe.zang, u.kleine-koenig, megi,
	sebastian.reichel, saikrishnag, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl, linux-kernel

On March 30, 2025 12:09:04 PM Arend Van Spriel 
<arend.vanspriel@broadcom.com> wrote:

> On March 30, 2025 11:35:41 AM Abdun Nihaal <abdun.nihaal@gmail.com> wrote:
>
>> The memory allocated for settings is not freed when brcmf_of_probe
>> fails. Fix that by freeing settings before returning in error path.
>>
>> Fixes: 0ff0843310b7 ("wifi: brcmfmac: Add optional lpo clock enable support")
>
> Good catch. Thanks for the fix.

The patch is fine, but a minor procedural nit that I should mention. The 
subject of patches for brcmfmac should have prefix "wifi: brcmfmac:" as 
shown in the Fixes: line. Hopefully Kalle can take care of that.

Regards,
Arend

>
> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
>> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
>> ---
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)




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

* Re: [PATCH] Fix memory leak in brcmf_get_module_param
  2025-03-30  9:35 [PATCH] Fix memory leak in brcmf_get_module_param Abdun Nihaal
  2025-03-30 10:09 ` Arend Van Spriel
@ 2025-03-30 11:33 ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-03-30 11:33 UTC (permalink / raw)
  To: Abdun Nihaal, brcm80211-dev-list.pdl, brcm80211, linux-wireless,
	Arend van Spriel
  Cc: LKML, Jacobe Zang, Jeff Johnson, Kalle Valo, Ondřej Jirman,
	Sai Krishna, Sebastian Reichel, Toke Høiland-Jørgensen,
	Uwe Kleine-König

> The memory allocated for settings is not freed when brcmf_of_probe
> fails. Fix that by freeing settings before returning in error path.

  failed?

* Would you like to append parentheses to any function names?

* See also:
  https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n631


Regards,
Markus

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

end of thread, other threads:[~2025-03-30 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-30  9:35 [PATCH] Fix memory leak in brcmf_get_module_param Abdun Nihaal
2025-03-30 10:09 ` Arend Van Spriel
2025-03-30 10:13   ` Arend Van Spriel
2025-03-30 11:33 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®