* [PATCH-for-5.2 v2] hw/rx/rx-gdbsim: Fix memory leak
@ 2020-10-30 13:49 Philippe Mathieu-Daudé
2020-10-30 18:49 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-30 13:49 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Yoshinori Sato, qemu-trivial,
Philippe Mathieu-Daudé, Markus Armbruster, Richard Henderson
As load_device_tree() returns allocated memory,
we need to free it.
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Fixes: bda19d7bb56 ("hw/rx: Add RX GDB simulator")
Reported-by: Coverity (CID 1432307: RESOURCE_LEAK)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2: NULL-initialize (Richard)
---
hw/rx/rx-gdbsim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c
index 417ec0564b3..d70865962e8 100644
--- a/hw/rx/rx-gdbsim.c
+++ b/hw/rx/rx-gdbsim.c
@@ -122,7 +122,7 @@ static void rx_gdbsim_init(MachineState *machine)
if (dtb_filename) {
ram_addr_t dtb_offset;
int dtb_size;
- void *dtb;
+ g_autofree void *dtb = NULL;
dtb = load_device_tree(dtb_filename, &dtb_size);
if (dtb == NULL) {
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH-for-5.2 v2] hw/rx/rx-gdbsim: Fix memory leak
2020-10-30 13:49 [PATCH-for-5.2 v2] hw/rx/rx-gdbsim: Fix memory leak Philippe Mathieu-Daudé
@ 2020-10-30 18:49 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2020-10-30 18:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-trivial, Peter Maydell, Markus Armbruster, Yoshinori Sato,
Richard Henderson
On 10/30/20 6:49 AM, Philippe Mathieu-Daudé wrote:
> As load_device_tree() returns allocated memory,
> we need to free it.
>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Fixes: bda19d7bb56 ("hw/rx: Add RX GDB simulator")
> Reported-by: Coverity (CID 1432307: RESOURCE_LEAK)
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> v2: NULL-initialize (Richard)
> ---
> hw/rx/rx-gdbsim.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c
> index 417ec0564b3..d70865962e8 100644
> --- a/hw/rx/rx-gdbsim.c
> +++ b/hw/rx/rx-gdbsim.c
> @@ -122,7 +122,7 @@ static void rx_gdbsim_init(MachineState *machine)
> if (dtb_filename) {
> ram_addr_t dtb_offset;
> int dtb_size;
> - void *dtb;
> + g_autofree void *dtb = NULL;
>
> dtb = load_device_tree(dtb_filename, &dtb_size);
What I said was, merge the declaration and statement:
g_autofree void *dtb =
load_device_tree(...);
but whatever. You can still keep my previous conditional r-b.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-30 18:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 13:49 [PATCH-for-5.2 v2] hw/rx/rx-gdbsim: Fix memory leak Philippe Mathieu-Daudé
2020-10-30 18:49 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).