Don't allow multiwrites against a block device without underlying medium
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
@@ -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]
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.
Signed-off-by Ryan Harper <[email protected]>---
v1->v2:
- movebs->drvcheck to top of function to match otherbdrv_functions
- fill out reqs response with error code before returning -1.
Quoted 2 lines
block.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
Stefan Hajnoczi
Reviewed-byI meant:
Kevin Wolf
AppliedAm 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.
Signed-off-by Ryan Harper <[email protected]>
Thanks, applied to the block branch.
Kevin
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.
Signed-off-by Ryan Harper <[email protected]>