* [PATCH] wifi: wilc1000: fix dma_buffer leak on bus acquire failure
@ 2026-05-10 11:25 Shitalkumar Gandhi
2026-05-11 4:27 ` [PATCH v2 v2] " Shitalkumar Gandhi
2026-05-11 4:32 ` [PATCH] " Shitalkumar Gandhi
0 siblings, 2 replies; 3+ messages in thread
From: Shitalkumar Gandhi @ 2026-05-10 11:25 UTC (permalink / raw)
To: ajay.kathat, claudiu.beznea
Cc: kvalo, linux-wireless, netdev, linux-kernel, Shitalkumar Patil
From: Shitalkumar Patil <shital@cambiumnetworks.com>
wilc_wlan_firmware_download() allocates dma_buffer with kmalloc() at
the top of the function and uses a 'fail:' label to free it via
kfree(dma_buffer) on error.
All later error paths correctly use 'goto fail' to route through this
cleanup. However, the early failure path after the first acquire_bus()
call uses a bare 'return ret;', which leaks dma_buffer whenever the bus
acquire fails.
Replace the early return with goto fail so the existing cleanup path
runs.
Found via a custom Coccinelle semantic patch hunting for kmalloc'd
locals leaked on early-return error paths in driver firmware-download
code.
Fixes: 1241c5650ff7 ("wifi: wilc1000: Fill in missing error handling")
Signed-off-by: Shitalkumar Patil <shital@cambiumnetworks.com>
---
drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 3fa8592eb250..4b116fe6f9ea 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -1265,7 +1265,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
ret = acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
if (ret)
- return ret;
+ goto fail;
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
reg &= ~BIT(10);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 v2] wifi: wilc1000: fix dma_buffer leak on bus acquire failure
2026-05-10 11:25 [PATCH] wifi: wilc1000: fix dma_buffer leak on bus acquire failure Shitalkumar Gandhi
@ 2026-05-11 4:27 ` Shitalkumar Gandhi
2026-05-11 4:32 ` [PATCH] " Shitalkumar Gandhi
1 sibling, 0 replies; 3+ messages in thread
From: Shitalkumar Gandhi @ 2026-05-11 4:27 UTC (permalink / raw)
To: ajay.kathat, claudiu.beznea
Cc: kvalo, linux-wireless, netdev, linux-kernel, Shitalkumar Gandhi
wilc_wlan_firmware_download() allocates dma_buffer with kmalloc() at
the top of the function and uses a 'fail:' label to free it via
kfree(dma_buffer) on error.
All later error paths correctly use 'goto fail' to route through this
cleanup. However, the early failure path after the first acquire_bus()
call uses a bare 'return ret;', which leaks dma_buffer whenever the bus
acquire fails.
Replace the early return with goto fail so the existing cleanup path
runs.
Found via a custom Coccinelle semantic patch hunting for kmalloc'd
locals leaked on early-return error paths in driver firmware-download
code.
Fixes: 1241c5650ff7 ("wifi: wilc1000: Fill in missing error handling")
Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>
---
Changes since v1:
- Corrected From: and Signed-off-by: to author's real identity
(Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>).
v1 was sent with incorrect author attribution due to a local
git config mistake. No code changes.
drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 3fa8592eb250..4b116fe6f9ea 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -1265,7 +1265,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
ret = acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
if (ret)
- return ret;
+ goto fail;
wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
reg &= ~BIT(10);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: wilc1000: fix dma_buffer leak on bus acquire failure
2026-05-10 11:25 [PATCH] wifi: wilc1000: fix dma_buffer leak on bus acquire failure Shitalkumar Gandhi
2026-05-11 4:27 ` [PATCH v2 v2] " Shitalkumar Gandhi
@ 2026-05-11 4:32 ` Shitalkumar Gandhi
1 sibling, 0 replies; 3+ messages in thread
From: Shitalkumar Gandhi @ 2026-05-11 4:32 UTC (permalink / raw)
To: ajay.kathat
Cc: claudiu.beznea, kvalo, linux-wireless, netdev, linux-kernel,
Shitalkumar Gandhi
Please disregard v1. The author attribution and Signed-off-by were
incorrect due to a local git config mistake. v2 with the corrected
identity has been sent and is threaded as a reply to this message.
Sorry for the noise.
Thanks,
Shital
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 4:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-10 11:25 [PATCH] wifi: wilc1000: fix dma_buffer leak on bus acquire failure Shitalkumar Gandhi
2026-05-11 4:27 ` [PATCH v2 v2] " Shitalkumar Gandhi
2026-05-11 4:32 ` [PATCH] " Shitalkumar Gandhi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox