drivers/crypto/starfive/jh7110-cryp.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
starfive_cryp_probe() publishes the crypto device after enabling its clocks
and deasserting its reset without checking whether those operations
succeeded.
Check each hardware activation step and unwind only the resources that were
actually enabled before returning the error.
Fixes: 42ef0e944b01 ("crypto: starfive - Add crypto engine support")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/crypto/starfive/jh7110-cryp.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/starfive/jh7110-cryp.c b/drivers/crypto/starfive/jh7110-cryp.c
index 842f76b0f1148..856290347b95b 100644
--- a/drivers/crypto/starfive/jh7110-cryp.c
+++ b/drivers/crypto/starfive/jh7110-cryp.c
@@ -120,9 +120,17 @@ static int starfive_cryp_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(cryp->rst),
"Error getting hardware reset line\n");
- clk_prepare_enable(cryp->hclk);
- clk_prepare_enable(cryp->ahb);
- reset_control_deassert(cryp->rst);
+ ret = clk_prepare_enable(cryp->hclk);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(cryp->ahb);
+ if (ret)
+ goto disable_hclk;
+
+ ret = reset_control_deassert(cryp->rst);
+ if (ret)
+ goto disable_ahb;
spin_lock(&dev_list.lock);
list_add(&cryp->list, &dev_list.dev_list);
@@ -170,9 +178,11 @@ static int starfive_cryp_probe(struct platform_device *pdev)
list_del(&cryp->list);
spin_unlock(&dev_list.lock);
- clk_disable_unprepare(cryp->hclk);
- clk_disable_unprepare(cryp->ahb);
reset_control_assert(cryp->rst);
+disable_ahb:
+ clk_disable_unprepare(cryp->ahb);
+disable_hclk:
+ clk_disable_unprepare(cryp->hclk);
return ret;
}
base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72
--
2.50.1
On Sun, Aug 30, 2026 at 09:48:35PM +0800, Pengpeng Hou wrote:
> starfive_cryp_probe() publishes the crypto device after enabling its clocks
> and deasserting its reset without checking whether those operations
> succeeded.
>
> Check each hardware activation step and unwind only the resources that were
> actually enabled before returning the error.
>
> Fixes: 42ef0e944b01 ("crypto: starfive - Add crypto engine support")
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/crypto/starfive/jh7110-cryp.c | 20 +++++++++++++++-----
> 1 file changed, 15 insertions(+), 5 deletions(-)
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
© 2016 - 2026 Red Hat, Inc.