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 <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2023-05-26 17:47:42 +02:00
parent d917883b30
commit ac76386eda

View File

@ -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 &&