From: Rosen Penev <rosenp@gmail.com>
To: linux-crypto@vger.kernel.org
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 2/2] crypto: img-hash: fix IRQ teardown ordering and fetch clocks early
Date: Tue, 11 Aug 2026 14:20:30 -0700 [thread overview]
Message-ID: <20260811212030.20057-3-rosenp@gmail.com> (raw)
In-Reply-To: <20260811212030.20057-1-rosenp@gmail.com>
The IRQ handler schedules tasklets, so free_irq must run before
tasklet_kill in img_hash_remove(). devm_request_irq only freed the
IRQ during devm unwind, after remove() returned, leaving a race in
which the handler could re-schedule a tasklet during teardown.
Replace it with request_irq and free the IRQ explicitly in remove()
and in the probe error path.
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/img-hash.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/img-hash.c b/drivers/crypto/img-hash.c
index f7265347901c..4153972ec3e7 100644
--- a/drivers/crypto/img-hash.c
+++ b/drivers/crypto/img-hash.c
@@ -125,6 +125,7 @@ struct img_hash_dev {
spinlock_t lock;
int err;
+ int irq;
struct tasklet_struct done_task;
struct tasklet_struct dma_task;
@@ -978,16 +979,16 @@ static int img_hash_probe(struct platform_device *pdev)
hdev->bus_addr = hash_res->start;
hdev->hash_clk = hash_clk;
hdev->sys_clk = sys_clk;
+ hdev->irq = irq;
- err = devm_request_irq(dev, irq, img_irq_handler, 0,
- dev_name(dev), hdev);
+ err = request_irq(hdev->irq, img_irq_handler, 0, dev_name(dev), hdev);
if (err)
goto res_err;
dev_dbg(dev, "using IRQ channel %d\n", irq);
err = img_hash_dma_init(hdev);
if (err)
- goto res_err;
+ goto err_irq;
dev_dbg(dev, "using %s for DMA transfers\n",
dma_chan_name(hdev->dma_lch));
@@ -1008,6 +1009,8 @@ static int img_hash_probe(struct platform_device *pdev)
list_del(&hdev->list);
spin_unlock(&img_hash.lock);
dma_release_channel(hdev->dma_lch);
+err_irq:
+ free_irq(hdev->irq, hdev);
res_err:
tasklet_kill(&hdev->done_task);
tasklet_kill(&hdev->dma_task);
@@ -1026,6 +1029,7 @@ static void img_hash_remove(struct platform_device *pdev)
img_unregister_algs(hdev);
+ free_irq(hdev->irq, hdev);
tasklet_kill(&hdev->done_task);
tasklet_kill(&hdev->dma_task);
--
2.55.0
prev parent reply other threads:[~2026-08-11 21:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 21:20 [PATCH 0/2] crypto: img-hash: clean up probe Rosen Penev
2026-08-11 21:20 ` [PATCH 1/2] crypto: img-hash: fetch resources into locals before probe body Rosen Penev
2026-08-11 21:20 ` Rosen Penev [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260811212030.20057-3-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.