If dm_bitset_cursor_begin fails, dm_array_cursor_end(&cmd->hint_cursor)
is called. However, cmd->hint_cursor was only initialized if the variable
hints_valid is true. Thus, we must also destroy hint_cursor only if
hints_valid is true.

Signed-off-by: Mikulas Patocka <[email protected]>
Assisted-by: Claude:claude-opus-5
Cc: [email protected]
Fixes: 629d0a8a1a10 ("dm cache metadata: add "metadata2" feature")

---
 drivers/md/dm-cache-metadata.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/md/dm-cache-metadata.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-cache-metadata.c
+++ linux-2.6/drivers/md/dm-cache-metadata.c
@@ -1433,7 +1433,8 @@ static int __load_mappings(struct dm_cac
                                           from_cblock(cmd->cache_blocks),
                                           &cmd->dirty_cursor);
                if (r) {
-                       dm_array_cursor_end(&cmd->hint_cursor);
+                       if (hints_valid)
+                               dm_array_cursor_end(&cmd->hint_cursor);
                        dm_array_cursor_end(&cmd->mapping_cursor);
                        return r;
                }


Reply via email to