mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: starfive: propagate clock and reset errors
@ 2026-08-30 13:48 Pengpeng Hou
  2026-09-23  8:47 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-08-30 13:48 UTC (permalink / raw)
  To: Jia Jie Ho
  Cc: Pengpeng Hou, William Qiu, Herbert Xu, David S . Miller,
	Philipp Zabel, linux-crypto, linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: starfive: propagate clock and reset errors
  2026-08-30 13:48 [PATCH] crypto: starfive: propagate clock and reset errors Pengpeng Hou
@ 2026-09-23  8:47 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-09-23  8:47 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Jia Jie Ho, William Qiu, David S . Miller, Philipp Zabel,
	linux-crypto, linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-23  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-30 13:48 [PATCH] crypto: starfive: propagate clock and reset errors Pengpeng Hou
2026-09-23  8:47 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®