diff options
Diffstat (limited to 'drivers/md/dm-table.c')
-rw-r--r-- | drivers/md/dm-table.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index e298d8d11f24..f3f952e347ed 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -189,8 +189,10 @@ static int alloc_targets(struct dm_table *t, unsigned int num) | |||
189 | 189 | ||
190 | /* | 190 | /* |
191 | * Allocate both the target array and offset array at once. | 191 | * Allocate both the target array and offset array at once. |
192 | * Append an empty entry to catch sectors beyond the end of | ||
193 | * the device. | ||
192 | */ | 194 | */ |
193 | n_highs = (sector_t *) dm_vcalloc(num, sizeof(struct dm_target) + | 195 | n_highs = (sector_t *) dm_vcalloc(num + 1, sizeof(struct dm_target) + |
194 | sizeof(sector_t)); | 196 | sizeof(sector_t)); |
195 | if (!n_highs) | 197 | if (!n_highs) |
196 | return -ENOMEM; | 198 | return -ENOMEM; |
@@ -867,6 +869,9 @@ struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index) | |||
867 | 869 | ||
868 | /* | 870 | /* |
869 | * Search the btree for the correct target. | 871 | * Search the btree for the correct target. |
872 | * | ||
873 | * Caller should check returned pointer with dm_target_is_valid() | ||
874 | * to trap I/O beyond end of device. | ||
870 | */ | 875 | */ |
871 | struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector) | 876 | struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector) |
872 | { | 877 | { |