Skip to contentSkip to conversation

stream: fix crash in stream_start() when block_job_create() fails

PATCH Applied Alberto Garcia 3 participants 3 messages May 15, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stream: fix crash in stream_start() when block_job_create() fails

The code that tries to reopen a BlockDriverState in stream_start() when the creation of a new block job fails crashes because it attempts to dereference a pointer that is known to be NULL.

This is a regression introduced in a170a91fd3eab6155da39e740381867e, likely because the code was copied from stream_complete().

---
 block/stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/stream.c +1 -1
index 0113710845..52d329f5c6 100644
@@ -280,6 +280,6 @@ void stream_start(const char *job_id, BlockDriverState *bs,
 
 fail:
     if (orig_bs_flags != bdrv_get_flags(bs)) {
-        bdrv_reopen(bs, s->bs_flags, NULL);
+        bdrv_reopen(bs, orig_bs_flags, NULL);
     }
 }
Signature · 1 line
2.11.0
Applied
#1 lore raw

Am 15.05.2017 um 11:34 hat Alberto Garcia geschrieben:

Quoted 8 lines

The code that tries to reopen a BlockDriverState in stream_start() when the creation of a new block job fails crashes because it attempts to dereference a pointer that is known to be NULL.

This is a regression introduced in a170a91fd3eab6155da39e740381867e, likely because the code was copied from stream_complete().

Thanks, applied to the block branch.

Kevin

Tested-by on v1 1/1
#2 lore raw
In reply to Alberto Garcia
Quoted 17 lines · Alberto Garcia

The code that tries to reopen a BlockDriverState in stream_start() when the creation of a new block job fails crashes because it attempts to dereference a pointer that is known to be NULL.

This is a regression introduced in a170a91fd3eab6155da39e740381867e, likely because the code was copied from stream_complete().

---
 block/stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/stream.c +0 -0
index 0113710845..52d329f5c6 100644

block/stream.c void stream_start(const char *job_id, BlockDriverState *bs, · line 283

Quoted 5 lines
block/stream.c +1 -1
@@ -280,6 +280,6 @@ void stream_start(const char *job_id, BlockDriverState *bs,
 
 fail:
     if (orig_bs_flags != bdrv_get_flags(bs)) {
-        bdrv_reopen(bs, s->bs_flags, NULL);
+        bdrv_reopen(bs, orig_bs_flags, NULL);

Yep, this fixes it.

It gracefully throws an error when a 'job-id' was not specified:

-----------------------------------------------------------------------
(QEMU) block-stream device=#block890 base=disk1.qcow2

{
    "execute": "block-stream", 
    "arguments": {
        "device": "#block890", 
        "base": "disk1.qcow2"
    }
}
{
    "error": {
        "class": "GenericError", 
        "desc": "An explicit job ID is required for this node"
    }
}
(QEMU) block-stream device=#block890 base=disk1.qcow2 job-id=job0
{
    "execute": "block-stream", 
    "arguments": {
        "device": "#block890", 
        "job-id": "job0", 
        "base": "disk1.qcow2"
    }
}
{
    "return": {}
}

(QEMU)
-----------------------------------------------------------------------

[...]

Signature · 1 line
/kashyap