Skip to content

Commit 219403d

Browse files
Ye Binsnitm
authored andcommitted
dm thin metadata: Avoid returning cmd->bm wild pointer on error
Maybe __create_persistent_data_objects() caller will use PTR_ERR as a pointer, it will lead to some strange things. Signed-off-by: Ye Bin <yebin10@huawei.com> Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent d16ff19 commit 219403d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/md/dm-thin-metadata.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,12 +739,16 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool f
739739
THIN_MAX_CONCURRENT_LOCKS);
740740
if (IS_ERR(pmd->bm)) {
741741
DMERR("could not create block manager");
742-
return PTR_ERR(pmd->bm);
742+
r = PTR_ERR(pmd->bm);
743+
pmd->bm = NULL;
744+
return r;
743745
}
744746

745747
r = __open_or_format_metadata(pmd, format_device);
746-
if (r)
748+
if (r) {
747749
dm_block_manager_destroy(pmd->bm);
750+
pmd->bm = NULL;
751+
}
748752

749753
return r;
750754
}

0 commit comments

Comments
 (0)