[PATCH v2025.09.y 34/58] firmware: xilinx-fpga: fix double free in probe error path
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Mar 13 06:25:18 PDT 2026
When firmwaremgr_register() fails, free(mgr) is called before jumping
to out_unreg. But the out: label (which out_unreg falls through to)
also calls free(mgr), resulting in a double free.
Remove the redundant free(mgr) before the goto, since the cleanup
labels already handle it.
(cherry picked from commit ca5f610b9232256a5e50e9722c74d082df4b484b)
Fixes: 2f4a47ef53 ("Added support for Zynq 7000 FPGA firmware loading")
Reported-by: GCC 14.2 -fanalyzer
Co-authored-by: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Link: https://lore.barebox.org/20260216084253.3547270-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/firmware/xilinx-fpga.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/firmware/xilinx-fpga.c b/drivers/firmware/xilinx-fpga.c
index 18d4e62ed1c3..7822521ef982 100644
--- a/drivers/firmware/xilinx-fpga.c
+++ b/drivers/firmware/xilinx-fpga.c
@@ -334,10 +334,8 @@ static int xilinx_fpga_probe(struct device *dev)
fh->device_node = dev->of_node;
ret = firmwaremgr_register(fh);
- if (ret != 0) {
- free(mgr);
+ if (ret != 0)
goto out_unreg;
- }
return 0;
out_unreg:
--
2.47.3
More information about the barebox
mailing list