From: SeokYeon Hwang <syeon.hwang@samsung.com>
To: "'Michael S. Tsirkin'" <mst@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com
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 [thread overview]
Message-ID: <040e01cff8fc$6d552f60$47ff8e20$@samsung.com> (raw)
In-Reply-To: <20141105124609.GA4354@redhat.com>
> -----Original Message-----
> From: Michael S. Tsirkin [mailto:mst@redhat.com]
> Sent: Wednesday, November 05, 2014 9:46 PM
> To: SeokYeon Hwang
> Cc: qemu-devel@nongnu.org; armbru@redhat.com; pbonzini@redhat.com
> 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 <syeon.hwang@samsung.com>
>
> 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
prev parent reply other threads:[~2014-11-05 13:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 10:11 [Qemu-devel] [PATCH] pci: fixed mismatch of error-handling between pci_qdev_init() and qdev SeokYeon Hwang
2014-11-05 10:59 ` Paolo Bonzini
2014-11-05 12:46 ` Michael S. Tsirkin
2014-11-05 13:16 ` Markus Armbruster
2014-11-05 13:18 ` Paolo Bonzini
2014-11-05 13:28 ` Michael S. Tsirkin
2014-11-05 14:55 ` Paolo Bonzini
2014-11-06 2:26 ` SeokYeon Hwang
2014-11-06 9:20 ` Markus Armbruster
2014-11-06 9:26 ` Michael S. Tsirkin
2014-11-06 9:41 ` SeokYeon Hwang
2014-11-06 9:23 ` Michael S. Tsirkin
2014-11-07 4:17 ` SeokYeon Hwang
2014-11-07 7:45 ` Markus Armbruster
2014-11-10 8:24 ` SeokYeon Hwang
2014-11-10 8:50 ` Markus Armbruster
2014-11-05 13:28 ` SeokYeon Hwang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='040e01cff8fc$6d552f60$47ff8e20$@samsung.com' \
--to=syeon.hwang@samsung.com \
--cc=armbru@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).