Skip to contentSkip to conversation

dm table: get_target: fix last index

PATCH New Alasdair G Kergon 1 participant 1 message May 30, 2006 Device mapper

lore
Share & tools
lore

Alasdair G Kergon

author maintainer
#0 lore raw

PATCH 1/1 dm table: get_target: fix last index

From: Milan Broz <[email protected]>

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.)

drivers/md/dm-table.c +1 -1
Index: linux-2.6.17-rc4/drivers/md/dm-table.c
===================================================================
@@ -802,7 +802,7 @@ sector_t dm_table_get_size(struct dm_tab
 
 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;