Skip to content

Commit

Permalink
hw/misc/applesmc: Fix memory leak in reset() handler
Browse files Browse the repository at this point in the history
AppleSMCData is allocated with g_new0() in applesmc_add_key():
release it with g_free().

Leaked since commit 1ddda5c ("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>
(cherry picked from commit fc09ff2)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
philmd authored and Michael Tokarev committed Apr 10, 2024
1 parent 8394be7 commit 9b7bc39
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions hw/misc/applesmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,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;
Expand Down

0 comments on commit 9b7bc39

Please sign in to comment.