From: Eduardo Habkost <ehabkost@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org,
Alistair Francis <alistair.francis@xilinx.com>
Subject: Re: [Qemu-arm] [Qemu-devel] [PATCH 1/5] xilinx: Fix error handling
Date: Thu, 6 Jul 2017 11:08:37 -0300 [thread overview]
Message-ID: <20170706140837.GE12152@localhost.localdomain> (raw)
In-Reply-To: <87fuebrtuk.fsf@dusky.pond.sub.org>
On Wed, Jul 05, 2017 at 01:44:35PM +0200, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
>
> > Assigning directly to *errp is not valid, as errp may be NULL,
> > &error_fatal, or &error_abort. Use error_propagate() instead.
> >
> > error_propagate() handles non-NULL *errp correctly, so the
> > "if (!*errp)" check can be removed.
> >
> > Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> > Cc: Alistair Francis <alistair.francis@xilinx.com>
> > Cc: Jason Wang <jasowang@redhat.com>
> > Cc: qemu-arm@nongnu.org
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > hw/dma/xilinx_axidma.c | 4 +---
> > hw/net/xilinx_axienet.c | 4 +---
> > 2 files changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
> > index 6065689ad1..3987b5ff96 100644
> > --- a/hw/dma/xilinx_axidma.c
> > +++ b/hw/dma/xilinx_axidma.c
> > @@ -554,9 +554,7 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
> > return;
> >
> > xilinx_axidma_realize_fail:
> > - if (!*errp) {
> > - *errp = local_err;
> > - }
> > + error_propagate(errp, local_err);
> > }
> >
> > static void xilinx_axidma_init(Object *obj)
> > diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
> > index b6701844d3..5ffa739f68 100644
> > --- a/hw/net/xilinx_axienet.c
> > +++ b/hw/net/xilinx_axienet.c
> > @@ -981,9 +981,7 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
> > return;
> >
> > xilinx_enet_realize_fail:
> > - if (!*errp) {
> > - *errp = local_err;
> > - }
> > + error_propagate(errp, local_err);
> > }
> >
> > static void xilinx_enet_init(Object *obj)
>
> The qdev core always passes &err. So this is "merely" a fix for a
> latent bug.
>
> If it could pass null, you'd fix a crash bug.
>
> If it could pass pointer to non-null (&error_fatal, &error_abort), you'd
> plug a memory leak.
>
> Suggest to rephrase the commit message:
>
> xilinx: Fix latent error handling bug
>
> Assigning directly to *errp is not valid, as errp may be null,
> &error_fatal, or &error_abort. The !*errp conditional protects
> against the latter two, but we then leak @local_err. Fortunately,
> the qdev core always passes pointer to null, so this is "merely" a
> latent bug.
>
> Use error_propagate() instead.
>
> What do you think?
Looks good to me. Do you want to fix it when applying?
>
> With something like that:
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
Thanks!
--
Eduardo
WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Habkost <ehabkost@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Jason Wang <jasowang@redhat.com>,
qemu-arm@nongnu.org,
Alistair Francis <alistair.francis@xilinx.com>
Subject: Re: [Qemu-devel] [PATCH 1/5] xilinx: Fix error handling
Date: Thu, 6 Jul 2017 11:08:37 -0300 [thread overview]
Message-ID: <20170706140837.GE12152@localhost.localdomain> (raw)
In-Reply-To: <87fuebrtuk.fsf@dusky.pond.sub.org>
On Wed, Jul 05, 2017 at 01:44:35PM +0200, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
>
> > Assigning directly to *errp is not valid, as errp may be NULL,
> > &error_fatal, or &error_abort. Use error_propagate() instead.
> >
> > error_propagate() handles non-NULL *errp correctly, so the
> > "if (!*errp)" check can be removed.
> >
> > Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> > Cc: Alistair Francis <alistair.francis@xilinx.com>
> > Cc: Jason Wang <jasowang@redhat.com>
> > Cc: qemu-arm@nongnu.org
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > hw/dma/xilinx_axidma.c | 4 +---
> > hw/net/xilinx_axienet.c | 4 +---
> > 2 files changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
> > index 6065689ad1..3987b5ff96 100644
> > --- a/hw/dma/xilinx_axidma.c
> > +++ b/hw/dma/xilinx_axidma.c
> > @@ -554,9 +554,7 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
> > return;
> >
> > xilinx_axidma_realize_fail:
> > - if (!*errp) {
> > - *errp = local_err;
> > - }
> > + error_propagate(errp, local_err);
> > }
> >
> > static void xilinx_axidma_init(Object *obj)
> > diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
> > index b6701844d3..5ffa739f68 100644
> > --- a/hw/net/xilinx_axienet.c
> > +++ b/hw/net/xilinx_axienet.c
> > @@ -981,9 +981,7 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
> > return;
> >
> > xilinx_enet_realize_fail:
> > - if (!*errp) {
> > - *errp = local_err;
> > - }
> > + error_propagate(errp, local_err);
> > }
> >
> > static void xilinx_enet_init(Object *obj)
>
> The qdev core always passes &err. So this is "merely" a fix for a
> latent bug.
>
> If it could pass null, you'd fix a crash bug.
>
> If it could pass pointer to non-null (&error_fatal, &error_abort), you'd
> plug a memory leak.
>
> Suggest to rephrase the commit message:
>
> xilinx: Fix latent error handling bug
>
> Assigning directly to *errp is not valid, as errp may be null,
> &error_fatal, or &error_abort. The !*errp conditional protects
> against the latter two, but we then leak @local_err. Fortunately,
> the qdev core always passes pointer to null, so this is "merely" a
> latent bug.
>
> Use error_propagate() instead.
>
> What do you think?
Looks good to me. Do you want to fix it when applying?
>
> With something like that:
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
Thanks!
--
Eduardo
next prev parent reply other threads:[~2017-07-06 14:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 13:39 [Qemu-devel] [PATCH 0/5] Error handling cleanup and fixes Eduardo Habkost
2017-06-08 13:39 ` [Qemu-arm] [PATCH 1/5] xilinx: Fix error handling Eduardo Habkost
2017-06-08 13:39 ` [Qemu-devel] " Eduardo Habkost
2017-06-08 16:29 ` [Qemu-arm] " Alistair Francis
2017-06-08 16:29 ` Alistair Francis
2017-07-05 11:44 ` [Qemu-arm] " Markus Armbruster
2017-07-05 11:44 ` Markus Armbruster
2017-07-06 14:08 ` Eduardo Habkost [this message]
2017-07-06 14:08 ` Eduardo Habkost
2017-07-06 14:45 ` [Qemu-arm] " Markus Armbruster
2017-07-06 14:45 ` Markus Armbruster
2017-06-08 13:39 ` [Qemu-devel] [PATCH 2/5] block: Don't try to set *errp directly Eduardo Habkost
2017-06-08 15:04 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-07-05 11:50 ` [Qemu-devel] " Markus Armbruster
2017-06-08 13:39 ` [Qemu-devel] [PATCH 3/5] websock: " Eduardo Habkost
2017-06-08 15:46 ` Manos Pitsidianakis
2017-07-05 11:53 ` Markus Armbruster
2017-06-08 13:39 ` [Qemu-devel] [PATCH 4/5] migration: " Eduardo Habkost
2017-06-08 14:18 ` Juan Quintela
2017-06-08 14:21 ` Dr. David Alan Gilbert
2017-06-08 14:22 ` Dr. David Alan Gilbert
2017-06-08 13:39 ` [Qemu-devel] [PATCH 5/5] vnc: No need for Error** parameter at vnc_client_io_error() Eduardo Habkost
2017-06-08 15:17 ` Eric Blake
2017-06-08 16:05 ` Eduardo Habkost
2017-06-08 17:44 ` Eduardo Habkost
2017-06-08 21:22 ` Eric Blake
2017-06-08 15:18 ` [Qemu-devel] [PATCH 0/5] Error handling cleanup and fixes Eric Blake
2017-07-05 11:56 ` Markus Armbruster
2017-07-06 15:10 ` Markus Armbruster
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=20170706140837.GE12152@localhost.localdomain \
--to=ehabkost@redhat.com \
--cc=alistair.francis@xilinx.com \
--cc=armbru@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-arm@nongnu.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.