Skip to contentSkip to conversation

wifi: brcmfmac: fix memory leak in brcmf_get_module_param

PATCH In review Abdun Nihaal 2 participants 2 messages Mar 30, 2025 Broadcom BRCM80211 IEEE802.11 wireless drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: brcmfmac: fix memory leak in brcmf_get_module_param

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")

---
V1 -> V2 : Add subsystem name in commit header as suggested by Arend

 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +3 -1
index cfcf01eb0daa..f26e4679e4ff 100644
@@ -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;
Signature · 1 line
2.47.2
#1 lore raw
Quoted 2 lines

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?

Regards,
Markus