summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2022-03-08 18:03:02 +0100
committerPeter Maydell2022-03-18 11:55:15 +0100
commit75f7ba165cea75594eb6bd5210119abe0d4c198a (patch)
treec2e3c0f93540c44692bbce77f25ea5c28ae7f71f
parenthw/dma/xlnx_csu_dma: Set TYPE_XLNX_CSU_DMA class_size (diff)
downloadqemu-75f7ba165cea75594eb6bd5210119abe0d4c198a.tar.gz
qemu-75f7ba165cea75594eb6bd5210119abe0d4c198a.tar.xz
qemu-75f7ba165cea75594eb6bd5210119abe0d4c198a.zip
hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init()
In npcm7xx_clk_sel_init() we allocate a string with g_strdup_printf(). Use g_autofree so we free it rather than leaking it. (Detected with the clang leak sanitizer.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20220308170302.2582820-1-peter.maydell@linaro.org
-rw-r--r--hw/misc/npcm7xx_clk.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 0b61070c52..bc2b879feb 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -612,8 +612,8 @@ static void npcm7xx_clk_sel_init(Object *obj)
NPCM7xxClockSELState *sel = NPCM7XX_CLOCK_SEL(obj);
for (i = 0; i < NPCM7XX_CLK_SEL_MAX_INPUT; ++i) {
- sel->clock_in[i] = qdev_init_clock_in(DEVICE(sel),
- g_strdup_printf("clock-in[%d]", i),
+ g_autofree char *s = g_strdup_printf("clock-in[%d]", i);
+ sel->clock_in[i] = qdev_init_clock_in(DEVICE(sel), s,
npcm7xx_clk_update_sel_cb, sel, ClockUpdate);
}
sel->clock_out = qdev_init_clock_out(DEVICE(sel), "clock-out");