* [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
* Re: [Qemu-devel] [Qemu-block] [PATCH] bdrv_inc_in_flight and bdrv_dec_in_flight:
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
2017-06-11 3:08 ` [Qemu-devel] " Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Manos Pitsidianakis @ 2017-06-11 1:31 UTC (permalink / raw)
To: Zhengui Li; +Cc: armbru, kwolf, mreitz, qemu-devel, qemu-block
[-- 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 --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] bdrv_inc_in_flight and bdrv_dec_in_flight:
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 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2017-06-11 3:08 UTC (permalink / raw)
To: Zhengui Li, armbru, kwolf, mreitz; +Cc: qemu-devel, qemu-block
[-- Attachment #1: Type: text/plain, Size: 549 bytes --]
On 06/10/2017 02:04 AM, Zhengui Li wrote:
> 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(-)
NACK; this is fixing a symptom, not the problem. If you have a coredump
due to a bad caller passing in NULL, then post the backtrace and let's
fix the broken caller instead.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [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).