From: Manos Pitsidianakis <el13635@mail.ntua.gr>
To: Zhengui Li <lizhengui@huawei.com>
Cc: armbru@redhat.com, kwolf@redhat.com, mreitz@redhat.com,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] bdrv_inc_in_flight and bdrv_dec_in_flight:
Date: Sun, 11 Jun 2017 04:31:14 +0300 [thread overview]
Message-ID: <20170611013114.okggmteznc3ittnx@postretch> (raw)
In-Reply-To: <1497078250-19505-1-git-send-email-lizhengui@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 1218 bytes --]
On Sat, Jun 10, 2017 at 03:04:10PM +0800, Zhengui Li wrote:
>Avoid empty pointer access if the bs is NULL.
Looks like most (if not all) of the places these are called dereference
bs anyway. Can it ever be NULL? Perhaps a check for each of those case
(if any) would be a better idea.
>Signed-off-by: Zhengui Li <lizhengui@huawei.com>
>---
> block/io.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
>diff --git a/block/io.c b/block/io.c
>index ed31810..b12d7cf 100644
>--- a/block/io.c
>+++ b/block/io.c
>@@ -492,7 +492,9 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req,
>
> void bdrv_inc_in_flight(BlockDriverState *bs)
> {
>- atomic_inc(&bs->in_flight);
>+ if (bs) {
>+ atomic_inc(&bs->in_flight);
>+ }
> }
>
> static void dummy_bh_cb(void *opaque)
>@@ -508,8 +510,10 @@ void bdrv_wakeup(BlockDriverState *bs)
>
> void bdrv_dec_in_flight(BlockDriverState *bs)
> {
>- atomic_dec(&bs->in_flight);
>- bdrv_wakeup(bs);
>+ if (bs) {
>+ atomic_dec(&bs->in_flight);
>+ bdrv_wakeup(bs);
>+ }
> }
>
> static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
>--
>1.8.3.1
>
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-06-11 1:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-10 7:04 [Qemu-devel] [PATCH] bdrv_inc_in_flight and bdrv_dec_in_flight: Zhengui Li
2017-06-11 1:31 ` Manos Pitsidianakis [this message]
2017-06-11 3:08 ` Eric Blake
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=20170611013114.okggmteznc3ittnx@postretch \
--to=el13635@mail.ntua.gr \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=lizhengui@huawei.com \
--cc=mreitz@redhat.com \
--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).