DMA Engine development
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Jaeyoung Chung <jjy600901@snu.ac.kr>
Cc: Frank Li <Frank.Li@kernel.org>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sangyun Kim <sangyun.kim@snu.ac.kr>,
	Kyungwook Boo <bookyungwook@gmail.com>
Subject: Re: dmaengine: k3dma: KASAN null-ptr-deref in k3_dma_int_handler() on early IRQ
Date: Thu, 11 Jun 2026 10:45:26 +0530	[thread overview]
Message-ID: <aipEbnW219G7U0eo@vaman> (raw)
In-Reply-To: <20260610104713.591381-1-jjy600901@snu.ac.kr>

On 10-06-26, 19:47, Jaeyoung Chung wrote:
> Hi,
> 
> k3_dma_probe() in drivers/dma/k3dma.c registers the interrupt handler
> with devm_request_irq() before it initializes d->phy. If an interrupt
> arrives before d->phy is initialized, k3_dma_int_handler() dereferences
> a NULL d->phy, causing a kernel panic.
> 
> The probe path, in k3_dma_probe():
> 
>     d = devm_kzalloc(&op->dev, sizeof(*d), GFP_KERNEL); /* d->phy == NULL */
>     ...
>     ret = devm_request_irq(&op->dev, irq,
>                            k3_dma_int_handler, 0, DRIVER_NAME, d); /* register handler */
>     ...
>     d->phy = devm_kcalloc(&op->dev,
>                           d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL); /* initialize d->phy */
> 
> The interrupt handler, k3_dma_int_handler(), dereferences d->phy without
> check:
> 
>     p = &d->phy[i];
>     c = p->vchan;   /* NULL pointer dereference */
> 
> If the device raises an interrupt before d->phy is initialized, the
> handler dereferences the NULL d->phy, triggering a KASAN
> null-ptr-deref.
> 
> Suggested fix: move the d->phy = devm_kcalloc() assignment above
> devm_request_irq(), so the d->phy array is valid before the
> handler can run.

Please send a patch

> 
> Reported-by: Sangyun Kim <sangyun.kim@snu.ac.kr>
> Reported-by: Kyungwook Boo <bookyungwook@gmail.com>
> 
> Thanks,
> Jaeyoung Chung

-- 
~Vinod

      reply	other threads:[~2026-06-11  5:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 10:47 dmaengine: k3dma: KASAN null-ptr-deref in k3_dma_int_handler() on early IRQ Jaeyoung Chung
2026-06-11  5:15 ` Vinod Koul [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=aipEbnW219G7U0eo@vaman \
    --to=vkoul@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=bookyungwook@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=jjy600901@snu.ac.kr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sangyun.kim@snu.ac.kr \
    /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