[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] microvm: check g_file_set_contents() return value
From: |
Peter Maydell |
Subject: |
Re: [PATCH 2/2] microvm: check g_file_set_contents() return value |
Date: |
Mon, 8 Nov 2021 15:35:51 +0000 |
On Mon, 8 Nov 2021 at 13:11, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Fixes: CID 1465239
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/i386/microvm-dt.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c
> index ad4e48e5fe60..774e0bc7fef3 100644
> --- a/hw/i386/microvm-dt.c
> +++ b/hw/i386/microvm-dt.c
> @@ -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__);
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