From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlyJc-0002dx-Hi for qemu-devel@nongnu.org; Wed, 05 Nov 2014 05:59:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlyJW-0007vp-Ip for qemu-devel@nongnu.org; Wed, 05 Nov 2014 05:59:52 -0500 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]:37672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlyJW-0007ve-8t for qemu-devel@nongnu.org; Wed, 05 Nov 2014 05:59:46 -0500 Received: by mail-la0-f43.google.com with SMTP id ge10so435092lab.30 for ; Wed, 05 Nov 2014 02:59:45 -0800 (PST) Sender: Paolo Bonzini Message-ID: <545A031D.7020704@redhat.com> Date: Wed, 05 Nov 2014 11:59:41 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1415182311-13799-1-git-send-email-syeon.hwang@samsung.com> In-Reply-To: <1415182311-13799-1-git-send-email-syeon.hwang@samsung.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] pci: fixed mismatch of error-handling between pci_qdev_init() and qdev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: SeokYeon Hwang , qemu-devel@nongnu.org Cc: armbru@redhat.com, mst@redhat.com On 05/11/2014 11:11, SeokYeon Hwang wrote: > pci_qdev_init() checks whether return value is 0 or not to figure out pci device is initialized successfully. Otherwise, device_realize() in qdev checks that return value is negative value to figure out the device is realized successfully. > When pci device returns positive number, pci_qdev_init() thinks that error is occured and makes the device unregistered. Nevertheless, qdev thinks that device is realized. > Finally, crash is occured by commands like 'qtree' that traverse qdev list. > > So, pci_qdev_init() returns -1 when init function returns not 0. > > Signed-off-by: SeokYeon Hwang > --- > hw/pci/pci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 371699c..c149fdf 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -1766,7 +1766,7 @@ static int pci_qdev_init(DeviceState *qdev) > rc = pc->init(pci_dev); > if (rc != 0) { > do_pci_unregister_device(pci_dev); > - return rc; > + return -1; > } > } > > Reviewed-by: Paolo Bonzini