hw/arm/sbsa-ref.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
Memory, allocated by the first call of g_strdup_printf() is lost at
the second call.
Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
---
hw/arm/sbsa-ref.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index ae37a92301..10984fc339 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -164,23 +164,17 @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
static void sbsa_fdt_add_gic_node(SBSAMachineState *sms)
{
- char *nodename;
-
- nodename = g_strdup_printf("/intc");
- qemu_fdt_add_subnode(sms->fdt, nodename);
- qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
+ qemu_fdt_add_subnode(sms->fdt, "/intc");
+ qemu_fdt_setprop_sized_cells(sms->fdt, "/intc", "reg",
2, sbsa_ref_memmap[SBSA_GIC_DIST].base,
2, sbsa_ref_memmap[SBSA_GIC_DIST].size,
2, sbsa_ref_memmap[SBSA_GIC_REDIST].base,
2, sbsa_ref_memmap[SBSA_GIC_REDIST].size);
- nodename = g_strdup_printf("/intc/its");
- qemu_fdt_add_subnode(sms->fdt, nodename);
- qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
+ qemu_fdt_add_subnode(sms->fdt, "/intc/its");
+ qemu_fdt_setprop_sized_cells(sms->fdt, "/intc/its", "reg",
2, sbsa_ref_memmap[SBSA_GIC_ITS].base,
2, sbsa_ref_memmap[SBSA_GIC_ITS].size);
-
- g_free(nodename);
}
/*
--
2.43.0
Hi Dmitry,
On 26/8/24 16:16, Dmitry Frolov wrote:
> Memory, allocated by the first call of g_strdup_printf() is lost at
> the second call.
>
> Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
> ---
> hw/arm/sbsa-ref.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index ae37a92301..10984fc339 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -164,23 +164,17 @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
>
> static void sbsa_fdt_add_gic_node(SBSAMachineState *sms)
> {
> - char *nodename;
> -
> - nodename = g_strdup_printf("/intc");
> - qemu_fdt_add_subnode(sms->fdt, nodename);
> - qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
> + qemu_fdt_add_subnode(sms->fdt, "/intc");
> + qemu_fdt_setprop_sized_cells(sms->fdt, "/intc", "reg",
> 2, sbsa_ref_memmap[SBSA_GIC_DIST].base,
> 2, sbsa_ref_memmap[SBSA_GIC_DIST].size,
> 2, sbsa_ref_memmap[SBSA_GIC_REDIST].base,
> 2, sbsa_ref_memmap[SBSA_GIC_REDIST].size);
>
> - nodename = g_strdup_printf("/intc/its");
> - qemu_fdt_add_subnode(sms->fdt, nodename);
> - qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
> + qemu_fdt_add_subnode(sms->fdt, "/intc/its");
> + qemu_fdt_setprop_sized_cells(sms->fdt, "/intc/its", "reg",
> 2, sbsa_ref_memmap[SBSA_GIC_ITS].base,
> 2, sbsa_ref_memmap[SBSA_GIC_ITS].size);
> -
> - g_free(nodename);
Thanks for your patch, but Peter posted a similar one last week:
https://lore.kernel.org/qemu-devel/20240822162323.706382-1-peter.maydell@linaro.org/
> }
>
> /*
© 2016 - 2026 Red Hat, Inc.