diff mbox series

Fix memory leak in brcmf_get_module_param

Message ID 20250330093505.22370-1-abdun.nihaal@gmail.com (mailing list archive)
State Superseded
Delegated to: Johannes Berg
Headers show
Series Fix memory leak in brcmf_get_module_param | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
wifibot/tree_selection success Guessed tree name to be wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_clang success Errors and warnings before: 0 this patch: 0
wifibot/build_32bit success Errors and warnings before: 0 this patch: 0
wifibot/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success No tools touched, skip
wifibot/check_selftest success No net selftest shell script
wifibot/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/kdoc success Errors and warnings before: 0 this patch: 0
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success Fixes tag looks correct
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Abdun Nihaal March 30, 2025, 9:35 a.m. UTC
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(-)

Comments

Arend Van Spriel March 30, 2025, 10:09 a.m. UTC | #1
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(-)
Arend Van Spriel March 30, 2025, 10:13 a.m. UTC | #2
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(-)
Markus Elfring March 30, 2025, 11:33 a.m. UTC | #3
> 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
diff mbox series

Patch

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;