qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] bdrv_inc_in_flight and bdrv_dec_in_flight:
@ 2017-06-10  7:04 Zhengui Li
  2017-06-11  1:31 ` [Qemu-devel] [Qemu-block] " Manos Pitsidianakis
  2017-06-11  3:08 ` [Qemu-devel] " Eric Blake
  0 siblings, 2 replies; 3+ messages in thread
From: Zhengui Li @ 2017-06-10  7:04 UTC (permalink / raw)
  To: armbru, kwolf, mreitz; +Cc: qemu-block, qemu-devel, lizhengui

Avoid empty pointer access if the bs is NULL.

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-11  3:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-10  7:04 [Qemu-devel] [PATCH] bdrv_inc_in_flight and bdrv_dec_in_flight: Zhengui Li
2017-06-11  1:31 ` [Qemu-devel] [Qemu-block] " Manos Pitsidianakis
2017-06-11  3:08 ` [Qemu-devel] " Eric Blake

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).