]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/misc/applesmc: Fix memory leak in reset() handler
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 8 Apr 2024 09:41:59 +0000 (11:41 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 10 Apr 2024 07:09:34 +0000 (09:09 +0200)
AppleSMCData is allocated with g_new0() in applesmc_add_key():
release it with g_free().

Leaked since commit 1ddda5cd36 ("AppleSMC device emulation").

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2272
Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20240408095217.57239-3-philmd@linaro.org>

hw/misc/applesmc.c

index 8e65816da6693df0d62ff4d6bf02d3cb7cbd26a6..14e3ef667d848b986081f082dbda5be3a20c1a49 100644 (file)
@@ -274,6 +274,7 @@ static void qdev_applesmc_isa_reset(DeviceState *dev)
     /* Remove existing entries */
     QLIST_FOREACH_SAFE(d, &s->data_def, node, next) {
         QLIST_REMOVE(d, node);
+        g_free(d);
     }
     s->status = 0x00;
     s->status_1e = 0x00;