[PATCH 01/12] firmware: xilinx-fpga: fix double free in probe error path
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 16 00:42:17 PST 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.
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>
---
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