From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH1F-0008Ox-Fd for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:46:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlH18-0008Vo-JS for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:46:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH18-0008Vi-Bd for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:45:54 -0500 Date: Mon, 3 Nov 2014 14:45:48 +0200 From: "Michael S. Tsirkin" Message-ID: <1415018633-16041-21-git-send-email-mst@redhat.com> References: <1415018633-16041-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1415018633-16041-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 20/29] hw/pci: fixed error flow in pci_qdev_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Markus Armbruster , Anthony Liguori , Marcel Apfelbaum From: Marcel Apfelbaum Verify return code for pci_add_option_rom. Signed-off-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Markus Armbruster --- 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 6ce75aa..36226eb 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1776,7 +1776,12 @@ static int pci_qdev_init(DeviceState *qdev) pci_dev->romfile = g_strdup(pc->romfile); is_default_rom = true; } - pci_add_option_rom(pci_dev, is_default_rom); + + rc = pci_add_option_rom(pci_dev, is_default_rom); + if (rc != 0) { + pci_unregister_device(DEVICE(pci_dev)); + return rc; + } return 0; } -- MST