[Concept,11/17] firmware: scmi: Fix memory leak in protocol list discovery

Message ID 20260316183050.3855921-12-sjg@u-boot.org
State New
Headers
Series Add automatic memory-leak detection to U-Boot tests |

Commit Message

Simon Glass March 16, 2026, 6:30 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The output buffer allocated in
scmi_base_discover_list_protocols_int() is freed on the error path
but not on the success path. Add the missing free(out) before
returning on success.

Fixes: ec8727b7e1c1 ("firmware: scmi: implement SCMI base protocol")
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/firmware/scmi/base.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/drivers/firmware/scmi/base.c b/drivers/firmware/scmi/base.c
index 78ee2ffd2da..d591b23d158 100644
--- a/drivers/firmware/scmi/base.c
+++ b/drivers/firmware/scmi/base.c
@@ -304,6 +304,7 @@  static int scmi_base_discover_list_protocols_int(struct udevice *dev,
 	} while (cur < num_protocols);
 
 	*protocols = buf;
+	free(out);
 
 	return num_protocols;
 err: