hw/gpio/pca9552: fix state_str leak in pca955x_set_led
visit_type_str() allocates state_str, but the function never frees it on any code path. Use g_autofree to ensure it is freed on return. Fixes: a90d8f84674d ("misc/pca9552: Add qom set and get") Reviewed-by: Glenn Miles <milesg@linux.ibm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Apr 27, 2026 at 16:04 UTC
700de17b85d728d90eba011c669ad43f89c9c43d
1 file changed
+1
-1
hw/gpio/pca9552.c
+1
-1
@@ -342,7 +342,7 @@ static void pca955x_set_led(Object *obj, Visitor *v, const char *name,
342
PCA955xState *s = PCA955X(obj);
343
int led, rc, reg, val;
344
uint8_t state;
345
- char *state_str;
345
+ g_autofree char *state_str = NULL;
346
347
if (!visit_type_str(v, name, &state_str, errp)) {
348
return;