Skip to contentSkip to conversation

Don't allow multiwrites against a block device without underlying medium

PATCH Applied Ryan Harper 4 participants 5 messages Mar 7, 2011 – Mar 30, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Don't allow multiwrites against a block device without underlying medium

If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io. This prevents a segfault further in the code where we dereference elements of the block driver.

---
v1->v2:
- move bs->drv check to top of function to match other bdrv_ functions
- fill out reqs response with error code before returning -1.

 block.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
block.c +8 -0
index f7d91a2..1544d81 100644
@@ -2398,6 +2398,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
     MultiwriteCB *mcb;
     int i;
 
+    /* don't submit writes if we don't have a medium */
+    if (bs->drv == NULL) {
+        for (i = 0; i < num_reqs; i++) {
+            reqs[i].error = -ENOMEDIUM;
+        }
+        return -1;
+    }
+
     if (num_reqs == 0) {
         return 0;
     }
Signature · 8 lines
1.7.1


-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
[email protected]
#1 lore raw
Quoted 12 lines · Ryan Harper

If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io.  This prevents a segfault further in the code where we dereference elements of the block driver.

---
v1->v2:
   - move bs->drv check to top of function to match other bdrv_ functions
   - fill out reqs response with error code before returning -1.

Quoted 2 lines

 block.c |    8 ++++++++

 1 files changed, 8 insertions(+), 0 deletions(-)
Applied
#3 lore raw
In reply to Ryan Harper

Am 07.03.2011 17:01, schrieb Ryan Harper:

Quoted 5 lines

If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io. This prevents a segfault further in the code where we dereference elements of the block driver.

Thanks, applied to the block branch.

Kevin

#4 lore raw
In reply to Ryan Harper

I think this (commit 301db7c2) should be cherry-picked into stable-0.14.

Quoted 5 lines · Ryan Harper

If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io. This prevents a segfault further in the code where we dereference elements of the block driver.