From: Peter Maydell Date: Thu, 6 Feb 2025 15:12:11 +0000 (+0000) Subject: hw/mips/boston: Check for error return from boston_fdt_filter() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=dfd0de718662a58ef2f2ef051939ed4b1a4d5ea7;p=qemu.git hw/mips/boston: Check for error return from boston_fdt_filter() The function boston_fdt_filter() can return NULL on errors (in which case it will print an error message). When we call this from the non-FIT-image codepath, we aren't checking the return value, so we will plough on with a NULL pointer, and segfault in fdt_totalsize(). Check for errors here. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20250206151214.2947842-4-peter.maydell@linaro.org --- diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 4690b254dd..de6ce1f163 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -810,6 +810,10 @@ static void boston_mach_init(MachineState *machine) dtb_load_data = boston_fdt_filter(s, dtb_file_data, NULL, &dtb_vaddr); + if (!dtb_load_data) { + /* boston_fdt_filter() already printed the error for us */ + exit(1); + } /* Calculate real fdt size after filter */ dt_size = fdt_totalsize(dtb_load_data);