Skip to content

Commit

Permalink
pci: refuse empty ROM files
Browse files Browse the repository at this point in the history
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 <milosivanovic@orcon.net.nz>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
stefanhaRH authored and mstsirkin committed Mar 26, 2013
1 parent ea7cfed commit 8c7f3dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hw/pci/pci.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8c7f3dd

Please sign in to comment.