Skip to content

Commit

Permalink
dm cache metadata: Avoid returning cmd->bm wild pointer on error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ye Bin authored and Mike Snitzer committed Sep 2, 2020
1 parent e27fec6 commit d16ff19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/md/dm-cache-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,16 @@ static int __create_persistent_data_objects(struct dm_cache_metadata *cmd,
CACHE_MAX_CONCURRENT_LOCKS);
if (IS_ERR(cmd->bm)) {
DMERR("could not create block manager");
return PTR_ERR(cmd->bm);
r = PTR_ERR(cmd->bm);
cmd->bm = NULL;
return r;
}

r = __open_or_format_metadata(cmd, may_format_device);
if (r)
if (r) {
dm_block_manager_destroy(cmd->bm);
cmd->bm = NULL;
}

return r;
}
Expand Down

0 comments on commit d16ff19

Please sign in to comment.