From: Mikulas Patocka Date: Wed, 1 Oct 2008 13:39:24 +0000 (+0100) Subject: dm: cope with access beyond end of device in dm_merge_bvec X-Git-Tag: v2.6.27-rc9~48^2~1 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=b01cd5ac43b00c49759c126c21e7d22c7e80b245;p=linux-2.6-omap-h63xx.git dm: cope with access beyond end of device in dm_merge_bvec 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 Signed-off-by: Alasdair G Kergon --- diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 469cec54f37..ace998ce59f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -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 @@ -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: