From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: vkoul@kernel.org, ludovic.desroches@microchip.com
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Frank.Li@kernel.org,
allen.lkml@gmail.com, dave.jiang@intel.com,
dmaengine@vger.kernel.org, andriy.shevchenko@linux.intel.com
Subject: [PATCH 2/2] dmaengine: idma64: Kill the channel tasklets in remove again
Date: Mon, 23 Nov 2026 00:53:07 +0000 [thread overview]
Message-ID: <20261123-dma-chancnt-v1-2-f0eea0a4bb63@gmail.com> (raw)
In-Reply-To: <20261123-dma-chancnt-v1-0-f0eea0a4bb63@gmail.com>
From: Suyuan Wang <stevewong@hust.edu.cn>
idma64_remove() frees the IRQ and then kills the channel tasklets, as
the comment there says, so that no tasklet scheduled by the interrupt
runs after removal:
for (i = 0; i < idma64->dma.chancnt; i++) {
...
tasklet_kill(&idma64c->vchan.task);
}
Since commit e81274cd6b52 ("dmaengine: add support to dynamic
register/unregister of channels"), dma_async_device_unregister()
unregisters each channel and decrements dma.chancnt for it, so the
count is 0 when this loop runs and no tasklet is killed. A tasklet
scheduled by an interrupt can then run after the devm-allocated idma64
and its channels have been freed.
Read the channel count before unregistering the device.
Found with a static analysis tool and checked by hand.
Fixes: e81274cd6b52 ("dmaengine: add support to dynamic register/unregister of channels")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
drivers/dma/idma64.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/idma64.c b/drivers/dma/idma64.c
index e3db213e564b..5d0df1defb14 100644
--- a/drivers/dma/idma64.c
+++ b/drivers/dma/idma64.c
@@ -604,6 +604,8 @@ static int idma64_probe(struct idma64_chip *chip)
static void idma64_remove(struct idma64_chip *chip)
{
struct idma64 *idma64 = chip->idma64;
+ /* dma_async_device_unregister() decrements dma.chancnt to 0 */
+ unsigned short nr_chan = idma64->dma.chancnt;
unsigned short i;
dma_async_device_unregister(&idma64->dma);
@@ -614,7 +616,7 @@ static void idma64_remove(struct idma64_chip *chip)
*/
devm_free_irq(chip->dev, chip->irq, idma64);
- for (i = 0; i < idma64->dma.chancnt; i++) {
+ for (i = 0; i < nr_chan; i++) {
struct idma64_chan *idma64c = &idma64->chan[i];
tasklet_kill(&idma64c->vchan.task);
--
2.34.1
prev parent reply other threads:[~2026-11-23 0:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 0:53 [PATCH 0/2] dmaengine: Kill " Suyuan Wang via B4 Relay
2026-11-23 0:53 ` [PATCH 1/2] dmaengine: at_xdmac: Kill the " Suyuan Wang via B4 Relay
2026-11-23 0:53 ` Suyuan Wang via B4 Relay [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=20261123-dma-chancnt-v1-2-f0eea0a4bb63@gmail.com \
--to=devnull+shyckless.gmail.com@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=allen.lkml@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=shyckless@gmail.com \
--cc=vkoul@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 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®