Skip to content

Commit

Permalink
dm: cope with access beyond end of device in dm_merge_bvec
Browse files Browse the repository at this point in the history
If for any reason dm_merge_bvec() is given an offset beyond the end of the
device, avoid an oops and always allow one page to be added to an empty bio.
We'll reject the I/O later after the bio is submitted.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Oct 1, 2008
1 parent 5037108 commit b01cd5a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,8 @@ static int dm_merge_bvec(struct request_queue *q,
goto out;

ti = dm_table_find_target(map, bvm->bi_sector);
if (!dm_target_is_valid(ti))
goto out_table;

/*
* Find maximum amount of I/O that won't need splitting
Expand All @@ -861,6 +863,7 @@ static int dm_merge_bvec(struct request_queue *q,
if (max_size && ti->type->merge)
max_size = ti->type->merge(ti, bvm, biovec, max_size);

out_table:
dm_table_put(map);

out:
Expand Down

0 comments on commit b01cd5a

Please sign in to comment.