Skip to content

Commit

Permalink
xen-blkback: check the number of iovecs before allocating a bios
Browse files Browse the repository at this point in the history
With the introduction of indirect segments we can receive requests
with a number of segments bigger than the maximum number of allowed
iovecs in a bios, so make sure that blkback doesn't try to allocate a
bios with more iovecs than BIO_MAX_PAGES

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
royger authored and konradwilk committed Jun 25, 2013
1 parent 294caaf commit 1e0f7a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/block/xen-blkback/blkback.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,8 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
seg[i].nsec << 9,
seg[i].offset) == 0)) {

bio = bio_alloc(GFP_KERNEL, nseg-i);
int nr_iovecs = min_t(int, (nseg-i), BIO_MAX_PAGES);
bio = bio_alloc(GFP_KERNEL, nr_iovecs);
if (unlikely(bio == NULL))
goto fail_put_bio;

Expand Down

0 comments on commit 1e0f7a2

Please sign in to comment.