microvm: check g_file_set_contents() return value

Fixes: CID 1465239
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-Id: <20211108130718.840216-3-kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2021-11-08 14:07:18 +01:00
parent 1b38ccc9a1
commit b9e5628ca5

View File

@ -336,7 +336,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__);