64 lines
2.0 KiB
Diff
64 lines
2.0 KiB
Diff
|
|
From 8ae86aa13df2128b46b421df14f6000f81312795 Mon Sep 17 00:00:00 2001
|
||
|
|
From: zhujun2 <zhujun2_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 4 Mar 2024 01:19:55 -0800
|
||
|
|
Subject: [PATCH] hw/misc/mps2-scc: Free MPS2SCC::oscclk[] array on finalize()
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
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 4fb013afcc added:
|
||
|
|
|
||
|
|
DEFINE_PROP_ARRAY("oscclk", MPS2SCC, num_oscclk, oscclk_reset,
|
||
|
|
qdev_prop_uint32, uint32_t),
|
||
|
|
|
||
|
|
but forgot to free the 'oscclk_reset' array. Do it in the
|
||
|
|
instance_finalize() handler.
|
||
|
|
|
||
|
|
Cc: qemu-stable@nongnu.org
|
||
|
|
Fixes: 4fb013afcc ("hw/misc/mps2-scc: Support configurable number of OSCCLK values") # v6.0.0+
|
||
|
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Message-id: 20231121174051.63038-4-philmd@linaro.org
|
||
|
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
||
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||
|
|
(cherry picked from commit 896dd6ff7b9f2575f1a908a07f26a70b58d8b675)
|
||
|
|
Signed-off-by: zhujun2 <zhujun2_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
hw/misc/mps2-scc.c | 8 ++++++++
|
||
|
|
1 file changed, 8 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
|
||
|
|
index b3b42a792c..fe5034db14 100644
|
||
|
|
--- a/hw/misc/mps2-scc.c
|
||
|
|
+++ b/hw/misc/mps2-scc.c
|
||
|
|
@@ -329,6 +329,13 @@ static void mps2_scc_realize(DeviceState *dev, Error **errp)
|
||
|
|
s->oscclk = g_new0(uint32_t, s->num_oscclk);
|
||
|
|
}
|
||
|
|
|
||
|
|
+static void mps2_scc_finalize(Object *obj)
|
||
|
|
+{
|
||
|
|
+ MPS2SCC *s = MPS2_SCC(obj);
|
||
|
|
+
|
||
|
|
+ g_free(s->oscclk_reset);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static const VMStateDescription mps2_scc_vmstate = {
|
||
|
|
.name = "mps2-scc",
|
||
|
|
.version_id = 3,
|
||
|
|
@@ -385,6 +392,7 @@ static const TypeInfo mps2_scc_info = {
|
||
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||
|
|
.instance_size = sizeof(MPS2SCC),
|
||
|
|
.instance_init = mps2_scc_init,
|
||
|
|
+ .instance_finalize = mps2_scc_finalize,
|
||
|
|
.class_init = mps2_scc_class_init,
|
||
|
|
};
|
||
|
|
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|