diff options
author | Ye Bin <yebin10@huawei.com> | 2020-09-01 08:25:42 +0200 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2020-09-02 19:38:24 +0200 |
commit | d16ff19e69ab57e08bf908faaacbceaf660249de (patch) | |
tree | c53e87cd4fa790bad01f45edcdc02b2e34361168 | |
parent | dm integrity: fix error reporting in bitmap mode after creation (diff) | |
download | linux-d16ff19e69ab57e08bf908faaacbceaf660249de.tar.xz linux-d16ff19e69ab57e08bf908faaacbceaf660249de.zip |
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>
-rw-r--r-- | drivers/md/dm-cache-metadata.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index 151aa95775be..af6d4f898e4c 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -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; } |