]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/gpio/pca9552: fix state_str leak in pca955x_set_led
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 4 May 2026 11:35:23 +0000 (15:35 +0400)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 12 May 2026 20:35:54 +0000 (22:35 +0200)
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>
Message-ID: <20260504-qom-tests-v2-35-ef7e3dc94f7a@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/gpio/pca9552.c

index dd3f1536b65e2c394730117b8c0bc5069d8b33d4..472d8ad9571584624ba12890155d6925d94ff4ca 100644 (file)
@@ -342,7 +342,7 @@ static void pca955x_set_led(Object *obj, Visitor *v, const char *name,
     PCA955xState *s = PCA955X(obj);
     int led, rc, reg, val;
     uint8_t state;
-    char *state_str;
+    g_autofree char *state_str = NULL;
 
     if (!visit_type_str(v, name, &state_str, errp)) {
         return;