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.

Signed-off-by: Mikulas Patocka <[email protected]>
Assisted-by: Claude:claude-opus-5

---
 drivers/md/persistent-data/dm-space-map-common.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/md/persistent-data/dm-space-map-common.c
===================================================================
--- linux-2.6.orig/drivers/md/persistent-data/dm-space-map-common.c
+++ 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;
 


Reply via email to