[PATCH v2025.09.y 35/58] driver: fix missing va_end in dev_add_alias error path

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Mar 13 06:25:19 PDT 2026


dev_add_alias() calls va_start(va, fmt) but returns -ENOMEM without
calling va_end(va) if the allocation fails.

Add the missing va_end(va) call before the error return.

(cherry picked from commit 4959ca1bf487b20552b99fc5f3e49aa43aa11476)

Fixes: d914ef13a9 ("driver: add support for device aliases")
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-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/base/driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index f15b252ea318..6a2a9efe66b0 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -637,8 +637,10 @@ int dev_add_alias(struct device *dev, const char *fmt, ...)
 	va_end(va_copy);
 
 	alias = malloc(struct_size(alias, name, len + 1));
-	if (!alias)
+	if (!alias) {
+		va_end(va);
 		return -ENOMEM;
+	}
 
 	vsnprintf(alias->name, len + 1, fmt, va);
 
-- 
2.47.3




More information about the barebox mailing list