qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] pci: fixed mismatch of error-handling between p


From: SeokYeon Hwang
Subject: Re: [Qemu-devel] [PATCH] pci: fixed mismatch of error-handling between pci_qdev_init() and qdev
Date: Wed, 05 Nov 2014 22:28:46 +0900

> -----Original Message-----
> From: Michael S. Tsirkin [mailto:address@hidden
> Sent: Wednesday, November 05, 2014 9:46 PM
> To: SeokYeon Hwang
> Cc: address@hidden; address@hidden; address@hidden
> Subject: Re: [PATCH] pci: fixed mismatch of error-handling between
> pci_qdev_init() and qdev
> 
> On Wed, Nov 05, 2014 at 07:11:51PM +0900, 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 <address@hidden>
> 
> Question: is there a simple way to trigger this error?

You can reproduce this error by changing the return value of the unimportant
device's init() to 1.
Actually, I found this bug through the device that is not exist in upstream
qemu.
(It is Tizen emulator's device.)

> 
> > ---
> >  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;
> >          }
> >      }
> >
> > --
> > 2.1.0




reply via email to

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