summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYe Bin <yebin10@huawei.com>2020-09-01 09:25:43 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-09 20:04:31 +0300
commit2c00ee626ed48c6ba1f10b8350a8c118846db9ce (patch)
tree83a47fe6713fbd58bf2e27c080c1e3e4c6efbdf4 /drivers
parent67f03c3d6829cf9c4b4015b24326a2cb7b8d6664 (diff)
downloadlinux-2c00ee626ed48c6ba1f10b8350a8c118846db9ce.tar.xz
dm thin metadata: Avoid returning cmd->bm wild pointer on error
commit 219403d7e56f9b716ad80ab87db85d29547ee73e upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-thin-metadata.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 6a26afcc1fd6..85077f4d257a 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -698,12 +698,16 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool f
THIN_MAX_CONCURRENT_LOCKS);
if (IS_ERR(pmd->bm)) {
DMERR("could not create block manager");
- return PTR_ERR(pmd->bm);
+ r = PTR_ERR(pmd->bm);
+ pmd->bm = NULL;
+ return r;
}
r = __open_or_format_metadata(pmd, format_device);
- if (r)
+ if (r) {
dm_block_manager_destroy(pmd->bm);
+ pmd->bm = NULL;
+ }
return r;
}