Skip to content

Commit 5ea0601

Browse files
tititiou36gregkh
authored andcommitted
hwrng: ingenic - Fix a resource leak in an error handling path
[ Upstream commit c4ff41b ] 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: 406346d ("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>
1 parent 39e0bdd commit 5ea0601

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎drivers/char/hw_random/ingenic-trng.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,17 @@ static int ingenic_trng_probe(struct platform_device *pdev)
113113
ret = hwrng_register(&trng->rng);
114114
if (ret) {
115115
dev_err(&pdev->dev, "Failed to register hwrng\n");
116-
return ret;
116+
goto err_unprepare_clk;
117117
}
118118

119119
platform_set_drvdata(pdev, trng);
120120

121121
dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n");
122122
return 0;
123+
124+
err_unprepare_clk:
125+
clk_disable_unprepare(trng->clk);
126+
return ret;
123127
}
124128

125129
static int ingenic_trng_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)