qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Jeff Cody <jcody@redhat.com>,
	peter.maydell@linaro.org, qemu-devel@nongnu.org,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-2.10] block/qapi: Remove redundat NULL check to silence Coverity
Date: Mon, 31 Jul 2017 17:13:00 +0200	[thread overview]
Message-ID: <20170731151300.GC12064@localhost.localdomain> (raw)
In-Reply-To: <5e788182-b778-e027-2250-8e7c643786ae@amsat.org>

Am 31.07.2017 um 16:54 hat Philippe Mathieu-Daudé geschrieben:
> On 07/31/2017 11:38 AM, Jeff Cody wrote:
> > On Mon, Jul 31, 2017 at 02:51:11PM +0200, Kevin Wolf wrote:
> > > When skipping implicit nodes in bdrv_block_device_info(), we know that
> > > bs0 is always non-NULL; initially, because it's taken from a BdrvChild
> > 
> > Not to mention, we deference bs0 in the chunk of code right above this, so
> > we'd segfault anyway if the initial value was NULL.

Not really. The last use of bs0 before the loop is:

    bs0 = bs0->backing->bs;bs0 = bs0->backing->bs;

So we're pointing to a different BDS now.

> Yes, please move your assert before:
> 
> 137:    if (bs0->drv && bs0->backing) {

That would assert something completely different and much more obvious.
(And apart from that, bdrv_query_image_info() in line 130 already
dereferences bs0, so it would be too late, too.)

What I want to assert here is that every implicit image has a backing
file.

Kevin

  reply	other threads:[~2017-07-31 15:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 12:51 [Qemu-devel] [PATCH for-2.10] block/qapi: Remove redundat NULL check to silence Coverity Kevin Wolf
2017-07-31 13:06 ` Eric Blake
2017-07-31 14:00   ` [Qemu-devel] [Qemu-block] " Eric Blake
2017-07-31 14:07     ` Kevin Wolf
2017-07-31 14:38 ` [Qemu-devel] " Jeff Cody
2017-07-31 14:54   ` Philippe Mathieu-Daudé
2017-07-31 15:13     ` Kevin Wolf [this message]
2017-07-31 15:17     ` Jeff Cody
2017-07-31 15:30       ` Philippe Mathieu-Daudé

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=20170731151300.GC12064@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jcody@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@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 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).