From: Stefan Hajnoczi Date: Mon, 11 Mar 2013 09:20:20 +0000 (+0100) Subject: pci: refuse empty ROM files X-Git-Tag: v1.5.0-rc0~409^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c7f3dd05e4f1ee90000c89e428e69ae2e6bd691;p=thirdparty%2Fqemu.git pci: refuse empty ROM files A zero size ROM file is invalid and should produce a warning. Attempting to use a zero size file ends up hitting an assertion qemu_ram_set_idstr() because RAMBlocks with duplicate addresses are allocated - due to zero size the allocator doesn't increment the next available RAMBlock offset. Also convert __FUNCTION__ to __func__ while we're touching this code. There are no other __FUNCTION__ instances in pci.c anymore. Reported-by: Milos Ivanovic Signed-off-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/pci/pci.c b/hw/pci/pci.c index f24c3896272..81028cb0831 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1912,7 +1912,12 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) size = get_image_size(path); if (size < 0) { error_report("%s: failed to find romfile \"%s\"", - __FUNCTION__, pdev->romfile); + __func__, pdev->romfile); + g_free(path); + return -1; + } else if (size == 0) { + error_report("%s: ignoring empty romfile \"%s\"", + __func__, pdev->romfile); g_free(path); return -1; }