summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-04-18 11:34:55 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-04-18 11:34:55 -0400
commite93504933ee6982bdc005fa5c24e1ea330faaf8b (patch)
tree4e775c9ab335e82cc5ffdbf54d49d8cb91f12adf /drivers
parent9f3aedf573dd034d59e7eb6c4ee97648d5be8fc6 (diff)
xen/blkback: Move the check for misaligned I/O once more.
The commit 976222e05ea5a9959ccf880d7a24efbf79b3c6cf xen/blkback: Move the check for misaligned I/O higher. moved it a bit to high. The preq->vbdev was not set, so the check for misaligned I/O would cause a NULL pointer derefence. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/xen/blkback/blkback.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/xen/blkback/blkback.c b/drivers/xen/blkback/blkback.c
index c645c83f900b..a0d3227955c9 100644
--- a/drivers/xen/blkback/blkback.c
+++ b/drivers/xen/blkback/blkback.c
@@ -514,6 +514,7 @@ static void dispatch_rw_block_io(struct blkif_st *blkif,
pending_req->operation = req->operation;
pending_req->status = BLKIF_RSP_OKAY;
pending_req->nr_pages = nseg;
+
for (i = 0; i < nseg; i++) {
seg[i].nsec = req->u.rw.seg[i].last_sect -
req->u.rw.seg[i].first_sect + 1;
@@ -522,12 +523,6 @@ static void dispatch_rw_block_io(struct blkif_st *blkif,
goto fail_response;
preq.nr_sects += seg[i].nsec;
- if (((int)preq.sector_number|(int)seg[i].nsec) &
- ((bdev_logical_block_size(preq.bdev) >> 9) - 1)) {
- DPRINTK("Misaligned I/O request from domain %d",
- blkif->domid);
- goto fail_response;
- }
}
if (vbd_translate(&preq, blkif, operation) != 0) {
@@ -537,6 +532,16 @@ static void dispatch_rw_block_io(struct blkif_st *blkif,
preq.sector_number + preq.nr_sects, preq.dev);
goto fail_response;
}
+ /* This check _MUST_ be done after vbd_translate as the preq.bdev
+ * is set there. */
+ for (i = 0; i < nseg; i++) {
+ if (((int)preq.sector_number|(int)seg[i].nsec) &
+ ((bdev_logical_block_size(preq.bdev) >> 9) - 1)) {
+ DPRINTK("Misaligned I/O request from domain %d",
+ blkif->domid);
+ goto fail_response;
+ }
+ }
/* If we have failed at this point, we need to undo the M2P override,
* set gnttab_set_unmap_op on all of the grant references and perform
* the hypercall to unmap the grants - that is all done in