From c8acdd77a62374507ed8e70d59e124269d999b75 Mon Sep 17 00:00:00 2001 From: Pengpeng Hou Date: Sun, 30 Aug 2026 21:48:35 +0800 Subject: [PATCH] crypto: starfive - propagate clock and reset errors 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 Signed-off-by: Herbert Xu --- drivers/crypto/starfive/jh7110-cryp.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/starfive/jh7110-cryp.c b/drivers/crypto/starfive/jh7110-cryp.c index c3830a7c1810..856290347b95 100644 --- a/drivers/crypto/starfive/jh7110-cryp.c +++ b/drivers/crypto/starfive/jh7110-cryp.c @@ -125,11 +125,12 @@ static int starfive_cryp_probe(struct platform_device *pdev) return ret; ret = clk_prepare_enable(cryp->ahb); - if (ret) { - clk_disable_unprepare(cryp->hclk); - return ret; - } - reset_control_deassert(cryp->rst); + 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); @@ -177,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; }