If __set_snapshot_details fails, the variable td is leaked - this prevents any other snapshot with the same id from being created.
Fix this by removing it from the list and freeing it. Signed-off-by: Mikulas Patocka <[email protected]> Assisted-by: Claude:claude-opus-5 Cc: [email protected] Fixes: 991d9fa02da0 ("dm: add thin provisioning target") --- drivers/md/dm-thin-metadata.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Index: linux-2.6/drivers/md/dm-thin-metadata.c =================================================================== --- linux-2.6.orig/drivers/md/dm-thin-metadata.c +++ linux-2.6/drivers/md/dm-thin-metadata.c @@ -1225,10 +1225,13 @@ static int __create_snap(struct dm_pool_ __close_device(td); if (r) - goto bad; + goto bad2; return 0; +bad2: + list_del(&td->list); + kfree(td); bad: dm_btree_remove(&pmd->tl_info, pmd->root, &key, &pmd->root); dm_btree_remove(&pmd->details_info, pmd->details_root,
