All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Baoquan He" <hebaoquan@kylinos.cn>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 11/13] media: nxp: imx8-isi: Don't use GFP_DMA when calling dma_alloc_coherent()
Date: Thu, 03 Sep 2026 11:37:49 +0000	[thread overview]
Message-ID: <20260903113749.E28281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903111836.1777265-12-hebaoquan@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Teardown symmetry violation in `mxc_isi_remove()` causing a NULL pointer dereference / Use-After-Free.
--

commit 846491721093e7e929fd40da0be5709669dc9e9f
Author: Baoquan He <hebaoquan@kylinos.cn>

media: nxp: imx8-isi: Don't use GFP_DMA when calling dma_alloc_coherent()

dma_alloc_coherent() allocates the DMA buffer with the device's
addressing limitation in mind. The DMA core picks the zone from the
device's coherent DMA mask and ignores GFP_DMA passed by the caller.
This commit removes the redundant GFP_DMA flag.

> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> index f45c2aae59ce9..fc907d357149e 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> @@ -773,7 +773,7 @@ static int mxc_isi_video_alloc_discard_buffers(struct mxc_isi_video *video)
>  
>  		buf->size = PAGE_ALIGN(video->pix.plane_fmt[i].sizeimage);
>  		buf->addr = dma_alloc_coherent(video->pipe->isi->dev, buf->size,
> -					       &buf->dma, GFP_DMA | GFP_KERNEL);
> +					       &buf->dma, GFP_KERNEL);
>  		if (!buf->addr) {
>  			mxc_isi_video_free_discard_buffers(video);
>  			return -ENOMEM;

[Severity: High]
This isn't a bug introduced by this patch, but looking at the teardown
sequence in drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c:

drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c:mxc_isi_remove() {
	...
	for (i = 0; i < isi->pdata->num_channels; ++i) {
		struct mxc_isi_pipe *pipe = &isi->pipes[i];

		mxc_isi_pipe_cleanup(pipe);
	}

	mxc_isi_v4l2_cleanup(isi);
	...
}

Does this code have a teardown symmetry violation causing a use-after-free or
NULL pointer dereference?

mxc_isi_pipe_cleanup(pipe) is called before mxc_isi_v4l2_cleanup(isi), freeing
the subdevice active state and setting it to NULL before the user-space
interfaces are unregistered.

Because mxc_isi_v4l2_cleanup() has not yet run, the video device nodes are
still fully registered.

Could a concurrent ioctl from user-space, such as VIDIOC_STREAMON, call
mxc_isi_vb2_prepare_streaming() -> mxc_isi_pipe_acquire() ->
v4l2_subdev_lock_and_get_active_state() and dereference the now-NULL
active_state?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903111836.1777265-1-hebaoquan@kylinos.cn?part=11

  reply	other threads:[~2026-09-03 11:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 11:18 [PATCH 00/13] Don't use GFP_DMA when calling dma_alloc_coherent Baoquan He
2026-09-03 11:18 ` [PATCH 01/13] gpu: ipu-v3: Don't use GFP_DMA when calling dma_alloc_coherent() Baoquan He
2026-09-03 11:18 ` [PATCH 02/13] drm/sti: Don't use GFP_DMA when calling dma_alloc_wc() Baoquan He
2026-09-03 11:29   ` sashiko-bot
2026-09-03 11:18 ` [PATCH 03/13] ALSA: n64: Don't use GFP_DMA when calling dma_alloc_coherent() Baoquan He
2026-09-03 11:18 ` [PATCH 04/13] spi: spi-ti-qspi: " Baoquan He
2026-09-03 11:18 ` [PATCH 05/13] fbdev: fsl-diu-fb: Don't use GFP_DMA when calling dmam_alloc_coherent() Baoquan He
2026-09-03 11:30   ` sashiko-bot
2026-09-03 11:18 ` [PATCH 06/13] usb: gadget: lpc32xx_udc: Don't use GFP_DMA when calling dma_alloc_coherent() Baoquan He
2026-09-03 11:18 ` [PATCH 07/13] usb: cdns3: " Baoquan He
2026-09-03 11:18 ` [PATCH 08/13] media: staging: imx: " Baoquan He
2026-09-03 11:18 ` [PATCH 09/13] spi: atmel: " Baoquan He
2026-09-03 11:18 ` [PATCH 10/13] media: imx7-media-csi: " Baoquan He
2026-09-03 11:36   ` sashiko-bot
2026-09-04 15:14   ` Frank Li
2026-09-03 11:18 ` [PATCH 11/13] media: nxp: imx8-isi: " Baoquan He
2026-09-03 11:37   ` sashiko-bot [this message]
2026-09-04 15:14   ` Frank Li
2026-09-03 11:18 ` [PATCH 12/13] mtd: rawnand: gpmi: " Baoquan He
2026-09-03 11:18   ` Baoquan He
2026-09-03 11:18 ` [PATCH 13/13] usb: cdns2: " Baoquan He

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=20260903113749.E28281F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=hebaoquan@kylinos.cn \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.