The dm-array library called vt->inc and vt->dec with invalid arguments. None of the users of the library actually use the callbacks, so the bug was latent.
Signed-off-by: Mikulas Patocka <[email protected]> Assisted-by: Claude:claude-opus-5 --- drivers/md/persistent-data/dm-array.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) Index: linux-2.6/drivers/md/persistent-data/dm-array.c =================================================================== --- linux-2.6.orig/drivers/md/persistent-data/dm-array.c +++ linux-2.6/drivers/md/persistent-data/dm-array.c @@ -196,18 +196,18 @@ static int alloc_ablock(struct dm_array_ static void fill_ablock(struct dm_array_info *info, struct array_block *ab, const void *value, unsigned int new_nr) { - uint32_t nr_entries, delta, i; + uint32_t nr_entries, i; struct dm_btree_value_type *vt = &info->value_type; BUG_ON(new_nr > le32_to_cpu(ab->max_entries)); BUG_ON(new_nr < le32_to_cpu(ab->nr_entries)); nr_entries = le32_to_cpu(ab->nr_entries); - delta = new_nr - nr_entries; - if (vt->inc) - vt->inc(vt->context, value, delta); - for (i = nr_entries; i < new_nr; i++) + for (i = nr_entries; i < new_nr; i++) { + if (vt->inc) + vt->inc(vt->context, value, 1); memcpy(element_at(info, ab, i), value, vt->size); + } ab->nr_entries = cpu_to_le32(new_nr); } @@ -228,7 +228,7 @@ static void trim_ablock(struct dm_array_ nr_entries = le32_to_cpu(ab->nr_entries); delta = nr_entries - new_nr; if (vt->dec) - vt->dec(vt->context, element_at(info, ab, new_nr - 1), delta); + vt->dec(vt->context, element_at(info, ab, new_nr), delta); ab->nr_entries = cpu_to_le32(new_nr); }
