[PATCH 02/12] driver: fix missing va_end in dev_add_alias error path

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 16 00:42:18 PST 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.

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>
---
 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 36a1fcda48c8..20beb1e9e6fa 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -649,8 +649,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