diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-11-21 18:40:51 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2023-11-27 15:27:46 +0000 |
commit | 6e782ffd555808378f69dd606641f0c4b5ca6120 (patch) | |
tree | 316fcdc2da7449b54a5a7de0da746632d1829215 /hw/input | |
parent | 4f10c66077e39969940d928077560665e155cac8 (diff) | |
download | qemu-6e782ffd555808378f69dd606641f0c4b5ca6120.zip qemu-6e782ffd555808378f69dd606641f0c4b5ca6120.tar.gz qemu-6e782ffd555808378f69dd606641f0c4b5ca6120.tar.bz2 |
hw/input/stellaris_gamepad: Free StellarisGamepad::keycodes[] array
Commit 0be6bfac62 ("qdev: Implement variable length array properties")
added the DEFINE_PROP_ARRAY() macro with the following comment:
* It is the responsibility of the device deinit code to free the
* @_arrayfield memory.
Commit a75f336b97 added:
DEFINE_PROP_ARRAY("keycodes", StellarisGamepad, num_buttons,
keycodes, qdev_prop_uint32, uint32_t),
but forgot to free the 'keycodes' array. Do it in the instance_finalize
handler.
Fixes: a75f336b97 ("hw/input/stellaris_input: Convert to qdev")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231121174051.63038-7-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/input')
-rw-r--r-- | hw/input/stellaris_gamepad.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 06a0c0c..9dfa620 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -63,6 +63,13 @@ static void stellaris_gamepad_realize(DeviceState *dev, Error **errp) qemu_input_handler_register(dev, &stellaris_gamepad_handler); } +static void stellaris_gamepad_finalize(Object *obj) +{ + StellarisGamepad *s = STELLARIS_GAMEPAD(obj); + + g_free(s->keycodes); +} + static void stellaris_gamepad_reset_enter(Object *obj, ResetType type) { StellarisGamepad *s = STELLARIS_GAMEPAD(obj); @@ -92,6 +99,7 @@ static const TypeInfo stellaris_gamepad_info[] = { .name = TYPE_STELLARIS_GAMEPAD, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(StellarisGamepad), + .instance_finalize = stellaris_gamepad_finalize, .class_init = stellaris_gamepad_class_init, }, }; |