Skip to content

Commit

Permalink
hw/nvram/xlnx-efuse: Free XlnxEFuse::ro_bits[] array on finalize()
Browse files Browse the repository at this point in the history
Commit 0be6bfa ("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 68fbcc3 added:

  DEFINE_PROP_ARRAY("read-only", XlnxEFuse, ro_bits_cnt, ro_bits,
                    qdev_prop_uint32, uint32_t),

but forgot to free the 'ro_bits' array. Do it in the instance_finalize
handler.

Cc: qemu-stable@nongnu.org
Fixes: 68fbcc3 ("hw/nvram: Introduce Xilinx eFuse QOM") # v6.2.0+
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20231121174051.63038-5-philmd@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
philmd authored and pm215 committed Nov 27, 2023
1 parent 896dd6f commit 49b3e28
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hw/nvram/xlnx-efuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ static void efuse_realize(DeviceState *dev, Error **errp)
}
}

static void efuse_finalize(Object *obj)
{
XlnxEFuse *s = XLNX_EFUSE(obj);

g_free(s->ro_bits);
}

static void efuse_prop_set_drive(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
Expand Down Expand Up @@ -280,6 +287,7 @@ static const TypeInfo efuse_info = {
.name = TYPE_XLNX_EFUSE,
.parent = TYPE_DEVICE,
.instance_size = sizeof(XlnxEFuse),
.instance_finalize = efuse_finalize,
.class_init = efuse_class_init,
};

Expand Down

0 comments on commit 49b3e28

Please sign in to comment.