Skip to contentSkip to conversation

dm persistent data: use the "end" value in sm_ll_find_common_free_block

PATCH New Mikulas Patocka 1 participant 1 message Nov 23 Device mapper

lore
Share & tools
lore

Mikulas Patocka

author maintainer
#0 lore raw

PATCH 1/1 dm persistent data: use the "end" value in sm_ll_find_common_free_block

sm_ll_find_common_free_block would ignore the argument "end". It didn't cause any data corruption, it just scanned more data than needed. This commit makes it stop at the "end" argument. In case the caller supplies wild value, this commit still clips it to new_ll->nr_blocks.

Assisted-by Claude:claude-opus-5
---
 drivers/md/persistent-data/dm-space-map-common.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/persistent-data/dm-space-map-common.c +1 -1
Index: linux-2.6/drivers/md/persistent-data/dm-space-map-common.c
===================================================================
@@ -397,7 +397,7 @@ int sm_ll_find_common_free_block(struct
 	uint32_t count;
 
 	do {
-		r = sm_ll_find_free_block(new_ll, begin, new_ll->nr_blocks, b);
+		r = sm_ll_find_free_block(new_ll, begin, min(end, new_ll->nr_blocks), b);
 		if (r)
 			break;