Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guoniu Zhou" <guoniu.zhou@oss.nxp.com>
Cc: Frank.Li@kernel.org, media-ci@linuxtv.org, imx@lists.linux.dev
Subject: Re: [PATCH v4 1/3] media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams
Date: Fri, 24 Jul 2026 08:02:14 +0000	[thread overview]
Message-ID: <20260724080215.7C36F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724-isi-v4-1-27df7b5f6060@oss.nxp.com>

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

Pre-existing issues:
- [High] Pre-existing NULL pointer dereference in `mxc_isi_crossbar_xlate_streams` when no remote pad is linked.
- [Medium] Using `BIT()` macro on 64-bit stream masks causes undefined behavior on 32-bit architectures.
--

--- Patch [1]: [PATCH v4 1/3] media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams ---
commit f312b9be3591414051fb03d9e8651437e1f95ef2
Author: Guoniu Zhou <guoniu.zhou@oss.nxp.com>

media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams

The ISI crossbar needs to properly enable multiple streams from different
virtual channels on the same input pad. This commit implements per-stream
state tracking by storing the input index and stream mask in the mxc_isi_pipe
structure to properly manage hardware state on enable and disable operations.

> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> index c580c831972ec..d9146a361e7d7 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> @@ -318,11 +318,26 @@ static int mxc_isi_crossbar_set_routing(struct v4l2_subdev *sd,

[ ... ]

>  static int mxc_isi_crossbar_enable_streams(struct v4l2_subdev *sd,
>  					   struct v4l2_subdev_state *state,
>  					   u32 pad, u64 streams_mask)
>  {
>  	struct mxc_isi_crossbar *xbar = to_isi_crossbar(sd);
> +	struct mxc_isi_pipe *pipe = &xbar->isi->pipes[pad - xbar->num_sinks];
>  	struct v4l2_subdev *remote_sd;
>  	struct mxc_isi_input *input;
>  	u64 sink_streams;

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential NULL
pointer dereference in mxc_isi_crossbar_xlate_streams() which is called
from here.

If userspace configures routing that points to a disconnected sink pad and
then attempts to enable streams, media_pad_remote_pad_first() can return
NULL:

mxc_isi_crossbar_xlate_streams() {
	...
	pad = media_pad_remote_pad_first(&xbar->pads[sink_pad]);
	sd = media_entity_to_v4l2_subdev(pad->entity);
	if (!sd) {
	...
}

Does the immediate dereference of pad->entity crash the kernel before the
subsequent if (!sd) validation can handle the missing entity?

[Severity: Medium]
This is also a pre-existing issue in mxc_isi_crossbar_xlate_streams(), but I
noticed that BIT() is used on 64-bit stream masks:

mxc_isi_crossbar_xlate_streams() {
	...
		if (route->source_pad != source_pad ||
		    !(source_streams & BIT(route->source_stream)))
			continue;

		sink_streams |= BIT(route->sink_stream);
	...
}

Since source_streams and sink_streams are u64, and BIT() evaluates to a
32-bit unsigned long on 32-bit architectures, can this cause an
out-of-bounds shift or incorrect stream mask calculations if userspace
uses stream IDs of 32 or greater?

Should BIT_ULL() be used instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-isi-v4-0-27df7b5f6060@oss.nxp.com?part=1

  reply	other threads:[~2026-07-24  8:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  7:52 [PATCH v4 0/3] imx8-isi: Format support enhancements Guoniu Zhou
2026-07-24  7:52 ` [PATCH v4 1/3] media: nxp: imx8-isi: Implement per-stream reference counting for multiplexed streams Guoniu Zhou
2026-07-24  8:02   ` sashiko-bot [this message]
2026-07-24 15:29   ` Frank Li
2026-07-24  7:52 ` [PATCH v4 2/3] media: nxp: imx8-isi: Add 16-bit raw Bayer format support guoniu.zhou
2026-07-24  7:52 ` [PATCH v4 3/3] media: nxp: imx8-isi: Add additional 32-bit RGB " Guoniu Zhou
2026-07-24  8:03   ` sashiko-bot
2026-07-24 15:30     ` Frank Li
2026-07-25  6:22       ` G.N. Zhou (OSS)

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=20260724080215.7C36F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=guoniu.zhou@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=media-ci@linuxtv.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox