diff options
author | Alistair Francis <alistair.francis@wdc.com> | 2021-07-15 09:01:22 +1000 |
---|---|---|
committer | Alistair Francis <alistair.francis@wdc.com> | 2021-07-15 09:35:46 +1000 |
commit | b3d8aa20692b1baed299790f4a65d6b0cfb1a0bc (patch) | |
tree | 4f291544450dcb5d3e1c52f103164cb2fe18b661 /hw/riscv/boot.c | |
parent | bb7e0cde3cbd59e8b7d6e0e9c67e11f76cbe64d4 (diff) | |
download | qemu-b3d8aa20692b1baed299790f4a65d6b0cfb1a0bc.zip qemu-b3d8aa20692b1baed299790f4a65d6b0cfb1a0bc.tar.gz qemu-b3d8aa20692b1baed299790f4a65d6b0cfb1a0bc.tar.bz2 |
hw/riscv/boot: Check the error of fdt_pack()
Coverity reports that we don't check the error result of fdt_pack(), so
let's save the result and assert that it is 0.
Fixes: Coverity CID 1458136
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Message-id: 07325315b49d5555269f76094e4bc5296e0643b9.1626303527.git.alistair.francis@wdc.com
Diffstat (limited to 'hw/riscv/boot.c')
-rw-r--r-- | hw/riscv/boot.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 0d38bb7..993bf89 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -182,7 +182,7 @@ uint32_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt) { uint32_t temp, fdt_addr; hwaddr dram_end = dram_base + mem_size; - int fdtsize = fdt_totalsize(fdt); + int ret, fdtsize = fdt_totalsize(fdt); if (fdtsize <= 0) { error_report("invalid device-tree"); @@ -198,7 +198,9 @@ uint32_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt) temp = MIN(dram_end, 3072 * MiB); fdt_addr = QEMU_ALIGN_DOWN(temp - fdtsize, 16 * MiB); - fdt_pack(fdt); + ret = fdt_pack(fdt); + /* Should only fail if we've built a corrupted tree */ + g_assert(ret == 0); /* copy in the device tree */ qemu_fdt_dumpdtb(fdt, fdtsize); |