* [PATCH] hwrng: ingenic - Fix a resource leak in an error handling path
@ 2020-12-19 7:52 Christophe JAILLET
2020-12-20 13:30 ` Zhou Yanjie
2021-01-02 22:08 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2020-12-19 7:52 UTC (permalink / raw)
To: mpm, herbert, zhouyanjie, aric.pzqi
Cc: linux-crypto, linux-kernel, kernel-janitors, Christophe JAILLET
In case of error, we should call 'clk_disable_unprepare()' to undo a
previous 'clk_prepare_enable()' call, as already done in the remove
function.
Fixes: 406346d22278 ("hwrng: ingenic - Add hardware TRNG for Ingenic X1830")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/char/hw_random/ingenic-trng.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/char/hw_random/ingenic-trng.c b/drivers/char/hw_random/ingenic-trng.c
index 954a8411d67d..0eb80f786f4d 100644
--- a/drivers/char/hw_random/ingenic-trng.c
+++ b/drivers/char/hw_random/ingenic-trng.c
@@ -113,13 +113,17 @@ static int ingenic_trng_probe(struct platform_device *pdev)
ret = hwrng_register(&trng->rng);
if (ret) {
dev_err(&pdev->dev, "Failed to register hwrng\n");
- return ret;
+ goto err_unprepare_clk;
}
platform_set_drvdata(pdev, trng);
dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n");
return 0;
+
+err_unprepare_clk:
+ clk_disable_unprepare(trng->clk);
+ return ret;
}
static int ingenic_trng_remove(struct platform_device *pdev)
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hwrng: ingenic - Fix a resource leak in an error handling path
2020-12-19 7:52 [PATCH] hwrng: ingenic - Fix a resource leak in an error handling path Christophe JAILLET
@ 2020-12-20 13:30 ` Zhou Yanjie
2021-01-02 22:08 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Zhou Yanjie @ 2020-12-20 13:30 UTC (permalink / raw)
To: Christophe JAILLET, mpm, herbert, aric.pzqi
Cc: linux-crypto, linux-kernel, kernel-janitors
Hi Christophe,
On 2020/12/19 下午3:52, Christophe JAILLET wrote:
> In case of error, we should call 'clk_disable_unprepare()' to undo a
> previous 'clk_prepare_enable()' call, as already done in the remove
> function.
>
> Fixes: 406346d22278 ("hwrng: ingenic - Add hardware TRNG for Ingenic X1830")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/char/hw_random/ingenic-trng.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Thanks for fixing it, and apologize for my carelessness.
Tested-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
> diff --git a/drivers/char/hw_random/ingenic-trng.c b/drivers/char/hw_random/ingenic-trng.c
> index 954a8411d67d..0eb80f786f4d 100644
> --- a/drivers/char/hw_random/ingenic-trng.c
> +++ b/drivers/char/hw_random/ingenic-trng.c
> @@ -113,13 +113,17 @@ static int ingenic_trng_probe(struct platform_device *pdev)
> ret = hwrng_register(&trng->rng);
> if (ret) {
> dev_err(&pdev->dev, "Failed to register hwrng\n");
> - return ret;
> + goto err_unprepare_clk;
> }
>
> platform_set_drvdata(pdev, trng);
>
> dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n");
> return 0;
> +
> +err_unprepare_clk:
> + clk_disable_unprepare(trng->clk);
> + return ret;
> }
>
> static int ingenic_trng_remove(struct platform_device *pdev)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwrng: ingenic - Fix a resource leak in an error handling path
2020-12-19 7:52 [PATCH] hwrng: ingenic - Fix a resource leak in an error handling path Christophe JAILLET
2020-12-20 13:30 ` Zhou Yanjie
@ 2021-01-02 22:08 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2021-01-02 22:08 UTC (permalink / raw)
To: Christophe JAILLET
Cc: mpm, zhouyanjie, aric.pzqi, linux-crypto, linux-kernel, kernel-janitors
On Sat, Dec 19, 2020 at 08:52:07AM +0100, Christophe JAILLET wrote:
> In case of error, we should call 'clk_disable_unprepare()' to undo a
> previous 'clk_prepare_enable()' call, as already done in the remove
> function.
>
> Fixes: 406346d22278 ("hwrng: ingenic - Add hardware TRNG for Ingenic X1830")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/char/hw_random/ingenic-trng.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-02 22:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19 7:52 [PATCH] hwrng: ingenic - Fix a resource leak in an error handling path Christophe JAILLET
2020-12-20 13:30 ` Zhou Yanjie
2021-01-02 22:08 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).