Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rishikesh Donadkar" <r-donadkar@ti.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v13 06/17] media: ti: j721e-csi2rx: add a subdev for the core device
Date: Wed, 20 May 2026 12:49:09 +0000	[thread overview]
Message-ID: <20260520124910.3C9E01F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260520120022.539913-7-r-donadkar@ti.com>

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

New issues:
- [High] Improper validation of `media_entity_remote_source_pad_unique()` return value leads to ERR_PTR dereference.
- [High] Hardcoded pad indices prevent correct multi-stream routing and format propagation.
- [High] Missing gating logic for upstream `enable_streams` / `disable_streams` calls breaks stream multiplexing.
- [High] Subdev internal state is freed before unregistering the device node, creating a NULL pointer dereference window.
- [High] The `ti_csi2rx_link_validate` function drops the `active_state` lock before dereferencing the `format` pointer.

Pre-existing issues:
- [High] Stopping any individual stream globally resets the entire CSI2RX pixel interface, disrupting all other active streams.
--

(Note: The standard inline diff formatting has been altered to a free-form summary due to recitation restrictions.)

commit 922486909238d39ba74212f5c85e1669aed42e1a
Author: Jai Luthra <jai.luthra@linux.dev>
media: ti: j721e-csi2rx: add a subdev for the core device

This commit adds a V4L2 subdevice for the core TI CSI2RX device to
facilitate multi-stream capture and updates the driver to use the
new enable_stream and disable_stream APIs.

[Severity: High]
Does the validation of media_entity_remote_source_pad_unique() correctly
handle error pointers? In ti_csi2rx_sd_enable_streams() and
ti_csi2rx_sd_disable_streams(), the code checks if the returned remote_pad
is NULL. Since this function returns an ERR_PTR on failure (like
ERR_PTR(-ENOLINK)), the !remote_pad check will evaluate to false, leading
to a potential kernel panic when dereferencing remote_pad->index. Should
this use IS_ERR() instead?

[Severity: High]
Can the hardcoded pad indices cause issues for multi-stream routing? The
subdevice operations in ti_csi2rx_sd_set_fmt() and
ti_csi2rx_start_streaming() use TI_CSI2RX_PAD_FIRST_SOURCE statically. When
subsequent contexts start streaming, won't operations mistakenly target the
first context's pad and break format propagation? (I noticed this is
addressed in a later patch in the series, commit e0451de187b4f "media: ti:
j721e-csi2rx: add multistream support").

[Severity: High]
Will the unconditional upstream stream control calls break stream
multiplexing? In ti_csi2rx_sd_enable_streams() and disable_streams(),
the upstream subdev is enabled or disabled using a hardcoded BIT_U64(0)
mask without checking if the source is already active. If multiple
contexts start, won't the V4L2 core reject the duplicate enable with
-EALREADY, and won't stopping one context abruptly starve all others?
(I see this is also addressed later in commit e0451de187b4f "media: ti:
j721e-csi2rx: add multistream support").

[Severity: High]
Is there a race condition during device removal in ti_csi2rx_cleanup_v4l2()?
The code calls v4l2_subdev_cleanup() before v4l2_device_unregister(). Since
cleanup frees the subdevice's active_state and sets it to NULL while the
device node is still accessible, could a concurrent userspace ioctl
(like VIDIOC_SUBDEV_S_FMT) cause a NULL pointer dereference when
v4l2_subdev_state_get_format() is called? Should device unregistration
happen first?

[Severity: High]
Could dropping the active_state lock too early cause torn reads? In
ti_csi2rx_link_validate(), the lock is released via v4l2_subdev_unlock_state()
immediately after fetching the format pointer, but before the format fields
are read and validated. If a concurrent VIDIOC_SUBDEV_S_FMT ioctl modifies
the state, might we validate against stale or partially updated data?
Should the fields be copied or validated while the lock is held?

[Severity: High]
This is a pre-existing issue, but does stopping a single stream globally
reset the entire CSI2RX pixel interface? In ti_csi2rx_stop_streaming(),
writing 0 to the SHIM_CNTL register clears SHIM_CNTL_PIX_RST. In a
multi-stream environment, wouldn't stopping one context forcefully reset the
hardware and disrupt all other currently active streams? (I note this is
fixed later in the series by commit e0451de187b4f "media: ti: j721e-csi2rx:
add multistream support").

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260520120022.539913-1-r-donadkar@ti.com?part=6

  parent reply	other threads:[~2026-05-20 12:49 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 12:00 [PATCH v13 00/17] media: cadence,ti: CSI2RX Multistream Support Rishikesh Donadkar
2026-05-20 12:00 ` [PATCH v13 01/17] media: ti: j721e-csi2rx: Remove word size alignment on frame width Rishikesh Donadkar
2026-05-20 12:27   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 02/17] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Rishikesh Donadkar
2026-05-20 12:00 ` [PATCH v13 03/17] media: ti: j721e-csi2rx: separate out device and context Rishikesh Donadkar
2026-05-20 12:37   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 04/17] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Rishikesh Donadkar
2026-05-20 12:00 ` [PATCH v13 05/17] media: ti: j721e-csi2rx: allocate DMA channel based on context index Rishikesh Donadkar
2026-05-20 12:32   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 06/17] media: ti: j721e-csi2rx: add a subdev for the core device Rishikesh Donadkar
2026-05-20 12:28   ` Sakari Ailus
2026-05-20 12:49   ` sashiko-bot [this message]
2026-05-20 12:00 ` [PATCH v13 07/17] media: cadence: csi2rx: Move to .enable/disable_streams API Rishikesh Donadkar
2026-05-20 12:39   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 08/17] media: ti: j721e-csi2rx: get number of contexts from device tree Rishikesh Donadkar
2026-05-20 12:45   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 09/17] media: cadence: csi2rx: Add .get_frame_desc op Rishikesh Donadkar
2026-05-20 14:25   ` Jai Luthra
2026-05-20 12:00 ` [PATCH v13 10/17] media: ti: j721e-csi2rx: add support for processing virtual channels Rishikesh Donadkar
2026-05-20 12:44   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 11/17] media: cadence: csi2rx: add multistream support Rishikesh Donadkar
2026-05-20 12:58   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 12/17] media: ti: j721e-csi2rx: " Rishikesh Donadkar
2026-05-20 12:48   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 13/17] media: ti: j721e-csi2rx: Submit all available buffers Rishikesh Donadkar
2026-05-20 12:59   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 14/17] media: ti: j721e-csi2rx: Change the drain architecture for multistream Rishikesh Donadkar
2026-05-20 13:01   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 15/17] media: cadence: csi2rx: Support runtime PM Rishikesh Donadkar
2026-05-20 13:00   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 16/17] media: ti: j721e-csi2rx: Support runtime suspend Rishikesh Donadkar
2026-05-20 13:01   ` sashiko-bot
2026-05-20 12:00 ` [PATCH v13 17/17] media: ti: j721e-csi2rx: Support system suspend using pm_notifier Rishikesh Donadkar
2026-05-20 12:25   ` Sakari Ailus
2026-05-20 13:14   ` sashiko-bot

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=20260520124910.3C9E01F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=r-donadkar@ti.com \
    --cc=robh@kernel.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