From: Milan Broz Date: Mon, 26 Jun 2006 07:27:27 +0000 (-0700) Subject: [PATCH] dm table: get_target: fix last index X-Git-Tag: v2.6.18-rc1~660 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=143535396c7ebd9395a931a000b3963f457712b8;p=linux-2.6 [PATCH] dm table: get_target: fix last index The table is indexed from 0, so an index equal to t->num_targets should be rejected. (There is no code in the current tree that would exercise this bug.) Signed-off-by: Milan Broz Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 8f56a54cf0..b6183eda81 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -802,7 +802,7 @@ sector_t dm_table_get_size(struct dm_table *t) struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index) { - if (index > t->num_targets) + if (index >= t->num_targets) return NULL; return t->targets + index;