hw/rx/rx-gdbsim: Fix memory leak
PATCH v3 1/1 hw/rx/rx-gdbsim: Fix memory leak
As load_device_tree() returns allocated memory,
we need to free it.
Cc Yoshinori Sato <[email protected]>
Fixes bda19d7bb56 ("hw/rx: Add RX GDB simulator")
Reported-by Coverity (CID 1432307: RESOURCE_LEAK)
Reviewed-by Richard Henderson <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
---
v3: Directly initialize the variable on declaration (Richard)
--- hw/rx/rx-gdbsim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/rx/rx-gdbsim.c +1 -2
@@ -122,9 +122,8 @@ static void rx_gdbsim_init(MachineState *machine)if (dtb_filename) {ram_addr_t dtb_offset;int dtb_size; -void *dtb; + g_autofree void *dtb = load_device_tree(dtb_filename, &dtb_size); - dtb =load_device_tree (dtb_filename, &dtb_size);if (dtb ==NULL ) {error_report ("Couldn't open dtb file %s" , dtb_filename);exit (1 );
Signature · 1 line
2.26.2
Philippe Mathieu-Daudé
AppliedQuoted 8 lines · Philippe Mathieu-Daudé
As
load_device_tree()returns allocated memory,
we need to free it.Cc Yoshinori Sato <[email protected]>Fixes bda19d7bb56 ("hw/rx: Add RX GDB simulator")Reported-by Coverity (CID 1432307: RESOURCE_LEAK)Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 5 lines
---
v3: Directly initialize the variable on declaration (Richard)--- hw/rx/rx-gdbsim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Thanks, applied to renesas-fixes.