diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2020-12-19 10:52:07 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-04 13:37:37 +0300 |
commit | 5ea0601513a70416814297fbed93e7b749991c46 (patch) | |
tree | 34f749881cd8750b2dafb106dd9cbdc8812d5c00 /drivers/char/hw_random | |
parent | 39e0bddeff36fe477e35ededb1fd270a2f692dcb (diff) | |
download | linux-5ea0601513a70416814297fbed93e7b749991c46.tar.xz |
hwrng: ingenic - Fix a resource leak in an error handling path
[ Upstream commit c4ff41b93d1f10d1b8be258c31a0436c5769fc00 ]
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>
Tested-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/char/hw_random')
-rw-r--r-- | drivers/char/hw_random/ingenic-trng.c | 6 |
1 files changed, 5 insertions, 1 deletions
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) |