qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] [PATCH] bdrv_inc_in_flight and bdrv_dec_in


From: Manos Pitsidianakis
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
User-agent: NeoMutt/20170113 (1.7.2)

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 <address@hidden>
---
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: signature.asc
Description: PGP signature


reply via email to

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