Skip to content

Commit d16ff19

Browse files
Ye Binsnitm
authored andcommitted
dm cache 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 e27fec6 commit d16ff19

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/md/dm-cache-metadata.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,16 @@ static int __create_persistent_data_objects(struct dm_cache_metadata *cmd,
537537
CACHE_MAX_CONCURRENT_LOCKS);
538538
if (IS_ERR(cmd->bm)) {
539539
DMERR("could not create block manager");
540-
return PTR_ERR(cmd->bm);
540+
r = PTR_ERR(cmd->bm);
541+
cmd->bm = NULL;
542+
return r;
541543
}
542544

543545
r = __open_or_format_metadata(cmd, may_format_device);
544-
if (r)
546+
if (r) {
545547
dm_block_manager_destroy(cmd->bm);
548+
cmd->bm = NULL;
549+
}
546550

547551
return r;
548552
}

0 commit comments

Comments
 (0)