2022-11-08 08:30:47

by Gaosheng Cui

[permalink] [raw]
Subject: [PATCH] crypto: ccree - Remove debugfs when platform_driver_register failed

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: 4c3f97276e15 ("crypto: ccree - introduce CryptoCell driver")
Signed-off-by: Gaosheng Cui <[email protected]>
---
drivers/crypto/ccree/cc_driver.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index cadead18b59e..d489c6f80892 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -651,9 +651,17 @@ static struct platform_driver ccree_driver = {

static int __init ccree_init(void)
{
+ int rc;
+
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);

--
2.25.1



2022-11-18 09:15:44

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: ccree - Remove debugfs when platform_driver_register failed

On Tue, Nov 08, 2022 at 04:29:12PM +0800, Gaosheng Cui wrote:
> 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: 4c3f97276e15 ("crypto: ccree - introduce CryptoCell driver")
> Signed-off-by: Gaosheng Cui <[email protected]>
> ---
> drivers/crypto/ccree/cc_driver.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt