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 <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>

authored by Mikulas Patocka and committed by Alasdair G Kergon b01cd5ac 5037108a

+3
+3
drivers/md/dm.c
··· 843 843 goto out; 844 844 845 845 ti = dm_table_find_target(map, bvm->bi_sector); 846 + if (!dm_target_is_valid(ti)) 847 + goto out_table; 846 848 847 849 /* 848 850 * Find maximum amount of I/O that won't need splitting ··· 863 861 if (max_size && ti->type->merge) 864 862 max_size = ti->type->merge(ti, bvm, biovec, max_size); 865 863 864 + out_table: 866 865 dm_table_put(map); 867 866 868 867 out: