qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] pci: refuse empty ROM files


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH 1/2] pci: refuse empty ROM files
Date: Mon, 11 Mar 2013 10:20:20 +0100

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 <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 hw/pci/pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2f45c8f..9d5907c 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1852,7 +1852,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;
     }
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]