microvm: fix Coverity warnings
cover microvm: fix Coverity warnings
Gerd Hoffmann (2):
microvm: add missing g_free() call
microvm: check g_file_set_contents() return value
hw/i386/microvm-dt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
PATCH 1/2 microvm: add missing g_free() call
Fixes CID 1465240
Signed-off-by Gerd Hoffmann <[email protected]>
--- hw/i386/microvm-dt.c | 2 ++ 1 file changed, 2 insertions(+)
hw/i386/microvm-dt.c +2 -0
@@ -143,6 +143,8 @@ static void dt_add_pcie(MicrovmMachineState *mms) nr_pcie_buses =PCIE_ECAM_SIZE /PCIE_MMCFG_SIZE_MIN ;qemu_fdt_setprop_cells (mms->fdt, nodename,"bus-range" ,0 , nr_pcie_buses -1 ); + +g_free (nodename); }static void dt_add_ioapic (MicrovmMachineState *mms,SysBusDevice *dev)
Signature · 1 line
2.31.1
Re: [PATCH 1/2] microvm: add missing g_free() call
Quoted 5 lines · Gerd Hoffmann
Fixes CID 1465240Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm-dt.c | 2 ++ 1 file changed, 2 insertions(+)
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
PATCH 2/2 microvm: check g_file_set_contents() return value
In reply to Gerd HoffmannFixes CID 1465239
Signed-off-by Gerd Hoffmann <[email protected]>
--- hw/i386/microvm-dt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/i386/microvm-dt.c +4 -1
@@ -334,7 +334,10 @@ void dt_setup_microvm(MicrovmMachineState *mms)if (debug) {fprintf (stderr,"%s: writing microvm.fdt\n" , __func__); -g_file_set_contents ("microvm.fdt" , mms->fdt, size,NULL ); +if (!g_file_set_contents ("microvm.fdt" , mms->fdt, size,NULL )) { +fprintf (stderr,"%s: writing microvm.fdt failed\n" , __func__); +return ; + }int ret =system ("dtc -I dtb -O dts microvm.fdt" );if (ret !=0 ) {fprintf (stderr,"%s: oops, dtc not installed?\n" , __func__);
Signature · 1 line
2.31.1
Re: [PATCH 2/2] microvm: check g_file_set_contents() return value
Quoted 13 lines · Gerd Hoffmann
Fixes CID 1465239Signed-off-by Gerd Hoffmann <[email protected]>--- hw/i386/microvm-dt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)hw/i386/microvm-dt.c +0
-0@@ -334,7 +334,10 @@ void dt_setup_microvm(MicrovmMachineState *mms)
hw/i386/microvm-dt.c void dt_setup_microvm(MicrovmMachineState *mms) · line 343
Quoted 10 lines
hw/i386/microvm-dt.c +4
-1if (debug) {fprintf (stderr,"%s: writing microvm.fdt\n" , __func__); -g_file_set_contents ("microvm.fdt" , mms->fdt, size,NULL ); +if (!g_file_set_contents ("microvm.fdt" , mms->fdt, size,NULL )) { +fprintf (stderr,"%s: writing microvm.fdt failed\n" , __func__); +return ; + }int ret =system ("dtc -I dtb -O dts microvm.fdt" );if (ret !=0 ) {fprintf (stderr,"%s: oops, dtc not installed?\n" , __func__);
Side note -- rather than invoking dtc from QEMU like this, it would be more in line with the way other machine types deal with debugging of autogenerated dtb files to support "-machine dumpdtb=file.dtb" and let the end user decompile the dtb themselves.
-- PMM