From f57a07068f7cc7ccdbf9814f9c69cbef1d2c9d6c Mon Sep 17 00:00:00 2001 Message-ID: From: Andrea Bolognani Date: Fri, 26 May 2023 17:47:42 +0200 Subject: [PATCH] qemu: Fix lookup against stateless/combined pflash Just like the more common split builds, these are of type QEMU_FIRMWARE_DEVICE_FLASH; however, they have no associated NVRAM template, so we can't access the corresponding structure member unconditionally or we'll trigger a crash. https://bugzilla.redhat.com/show_bug.cgi?id=2196178 Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik (cherry picked from commit ac76386edad3be2bbd6202a30063b9205011f5c5) https://bugzilla.redhat.com/show_bug.cgi?id=2196178 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_firmware.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 5f030ebce4..b1d342563b 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -971,9 +971,12 @@ qemuFirmwareMatchesPaths(const qemuFirmware *fw, if (loader && loader->path && STRNEQ(loader->path, flash->executable.filename)) return false; - if (loader && loader->nvramTemplate && - STRNEQ(loader->nvramTemplate, flash->nvram_template.filename)) - return false; + if (loader && loader->nvramTemplate) { + if (flash->mode != QEMU_FIRMWARE_FLASH_MODE_SPLIT) + return false; + if (STRNEQ(loader->nvramTemplate, flash->nvram_template.filename)) + return false; + } break; case QEMU_FIRMWARE_DEVICE_MEMORY: if (loader && loader->path && -- 2.42.0