crypto: ccree - Remove debugfs when platform_driver_register failed

[ Upstream commit 4f1c596df7 ]

When platform_driver_register failed, we need to remove debugfs,
which will caused a resource leak, fix it.

Failed logs as follows:
[   32.606488] debugfs: Directory 'ccree' with parent '/' already present!

Fixes: 4c3f97276e ("crypto: ccree - introduce CryptoCell driver")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Gaosheng Cui 2022-11-08 16:29:12 +08:00 committed by Greg Kroah-Hartman
parent 953c81ffe3
commit 677f01f396
1 changed files with 9 additions and 1 deletions

View File

@ -651,9 +651,17 @@ static struct platform_driver ccree_driver = {
static int __init ccree_init(void) static int __init ccree_init(void)
{ {
int rc;
cc_debugfs_global_init(); cc_debugfs_global_init();
return platform_driver_register(&ccree_driver); rc = platform_driver_register(&ccree_driver);
if (rc) {
cc_debugfs_global_fini();
return rc;
}
return 0;
} }
module_init(ccree_init); module_init(ccree_init);