* [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init()
@ 2022-03-08 17:03 Peter Maydell
2022-03-08 17:21 ` Richard Henderson
2022-03-08 17:28 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2022-03-08 17:03 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: Tyrone Ting, Havard Skinnemoen
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>
---
hw/misc/npcm7xx_clk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 0b61070c52f..bc2b879feb5 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");
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init()
2022-03-08 17:03 [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init() Peter Maydell
@ 2022-03-08 17:21 ` Richard Henderson
2022-03-08 18:53 ` Hao Wu
2022-03-08 17:28 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2022-03-08 17:21 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Tyrone Ting, Havard Skinnemoen
On 3/8/22 07:03, Peter Maydell wrote:
> 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>
> ---
> hw/misc/npcm7xx_clk.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init()
2022-03-08 17:03 [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init() Peter Maydell
2022-03-08 17:21 ` Richard Henderson
@ 2022-03-08 17:28 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-08 17:28 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Tyrone Ting, Havard Skinnemoen
On 8/3/22 18:03, Peter Maydell wrote:
> 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>
> ---
> hw/misc/npcm7xx_clk.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init()
2022-03-08 17:21 ` Richard Henderson
@ 2022-03-08 18:53 ` Hao Wu
0 siblings, 0 replies; 4+ messages in thread
From: Hao Wu @ 2022-03-08 18:53 UTC (permalink / raw)
To: Richard Henderson
Cc: Peter Maydell, qemu-arm, QEMU Developers, Tyrone Ting, Havard Skinnemoen
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
On Tue, Mar 8, 2022 at 10:09 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> On 3/8/22 07:03, Peter Maydell wrote:
> > 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>
> > ---
> > hw/misc/npcm7xx_clk.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> Reviewed-by: Hao Wu <wuhaotsh@google.com>
> r~
>
>
[-- Attachment #2: Type: text/html, Size: 1319 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-08 18:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 17:03 [PATCH] hw/misc/npcm7xx_clk: Don't leak string in npcm7xx_clk_sel_init() Peter Maydell
2022-03-08 17:21 ` Richard Henderson
2022-03-08 18:53 ` Hao Wu
2022-03-08 17:28 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.