hw/rx/rx-gdbsim: Fix memory leak
As load_device_tree() returns allocated memory,
we need to free it.
---
Peter mentioned this issue almost 2 months ago:
https://www.mail-archive.com/[email protected]/msg737946.html
Having helped Yoshinori to get his code merged, I feel the reponsibility of fixing this before the release. I know I am wrong, but since he is not responding to the review comments and we are in soft-freeze, I prefer to do the dirty laundry before we release.
--- hw/rx/rx-gdbsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/rx/rx-gdbsim.c +1 -1
@@ -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; dtb =load_device_tree (dtb_filename, &dtb_size);if (dtb ==NULL ) {
Signature · 1 line
2.26.2
Richard Henderson
Reviewed-byQuoted 3 lines · Philippe Mathieu-Daudé
+
g_autofreevoid *dtb;dtb = load_device_tree(dtb_filename, &dtb_size);
With g_autofree, we must initialize the variable on declaration. Often this is with NULL, but in this case, just merge these two lines.
With that,
r~
Quoted 7 lines · Richard Henderson
Quoted 3 lines · Philippe Mathieu-Daudé
+
g_autofreevoid *dtb;dtb = load_device_tree(dtb_filename, &dtb_size);With
g_autofree, we must initialize the variable on declaration. Often this is with NULL, but in this case, just merge these two lines.
OK.
Quoted 3 lines
With that,
Reviewed-by Richard Henderson <[email protected]>
Thanks!