Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: conor+dt@kernel.org, media-ci@linuxtv.org, robh@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 9/9] media: synopsys: hdmirx: get the 5V state from the upstream subdev
Date: Wed, 23 Sep 2026 14:05:44 +0000	[thread overview]
Message-ID: <20260923140544.B44771F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260923-hdmirx-media-v1-9-ea3d77d4a5f3@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] media: synopsys: hdmirx: UAF/Null dereference in hdmirx_notify() during teardown
--

commit c68bf2a72fd61990cd4b4472b5560e917e6f7cb9
Author: Gerald Loacker <gerald.loacker@wolfvision.net>

media: synopsys: hdmirx: get the 5V state from the upstream subdev

On a board whose HDMI connector belongs to a device in front of this
receiver, the connector's +5V line goes to that device and hpd-gpios is
absent. tx_5v_power_present() then reads a NULL descriptor, which
gpiod_get_value_cansleep() reports as zero, so the receiver never sees a
source and hdmirx_plugin() never runs.

> diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> index 23b4dd853be57..43d7857b4458b 100644
> --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
[ ... ]
> @@ -2673,6 +2736,18 @@ static int hdmirx_register_cec(struct snps_hdmirx_dev *hdmirx_dev,
>  	return 0;
>  }
>  
> +static void hdmirx_notify(struct v4l2_subdev *sd, unsigned int notification,
> +			  void *arg)
> +{
> +	struct snps_hdmirx_dev *hdmirx_dev =
> +		container_of(sd->v4l2_dev, struct snps_hdmirx_dev, v4l2_dev);
> +
> +	if (notification != V4L2_DEVICE_NOTIFY_RX_POWER_PRESENT || !arg)
> +		return;
> +
> +	hdmirx_5v_source_edge(hdmirx_dev, !!*(unsigned int *)arg);
> +}
> +

[Severity: High]
Does this code introduce a potential NULL pointer dereference or use-after-free
regression during teardown?

During driver unbind, hdmirx_remove() calls v4l2_async_nf_unregister(), which
can set sd->v4l2_dev to NULL. Since the subdevice's IRQ remains active, it
could concurrently send a notification via v4l2_subdev_notify(). If
hdmirx_notify() is called during this time, sd->v4l2_dev may be NULL, causing
a bogus pointer dereference via container_of() and subsequently in
hdmirx_5v_source_edge().

[ ... ]
> @@ -2926,6 +3038,9 @@ static void hdmirx_remove(struct platform_device *pdev)
>  	v4l2_async_nf_unregister(&hdmirx_dev->notifier);
>  	v4l2_async_nf_cleanup(&hdmirx_dev->notifier);
>  
> +	/* The unbind above arms the hotplug work again. */
> +	cancel_delayed_work_sync(&hdmirx_dev->delayed_work_hotplug);

[Severity: High]
Can asynchronous subdevice notifications re-arm the hotplug work after this
cancel_delayed_work_sync() call?

If a subdevice notification fires after this line, hdmirx_notify() could queue
delayed_work_hotplug on a freed hdmirx_dev, leading to a use-after-free
regression.

> +
>  	media_device_unregister(&hdmirx_dev->mdev);
>  
>  	vb2_video_unregister_device(&hdmirx_dev->stream.vdev);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260923-hdmirx-media-v1-0-ea3d77d4a5f3@pengutronix.de?part=9

      reply	other threads:[~2026-09-23 14:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 13:44 [PATCH 0/9] media: synopsys: hdmirx: support an HDMI bridge in front of the receiver Sascha Hauer
2026-09-23 13:44 ` [PATCH 1/9] media: synopsys: hdmirx: add media device infrastructure Sascha Hauer
2026-09-23 13:44 ` [PATCH 2/9] media: synopsys: hdmirx: add media entity for video capture device Sascha Hauer
2026-09-23 13:44 ` [PATCH 3/9] dt-bindings: media: snps,dw-hdmi-rx: add the source port Sascha Hauer
2026-09-23 16:34   ` Conor Dooley
2026-09-23 13:44 ` [PATCH 4/9] media: synopsys: hdmirx: add async subdevice support Sascha Hauer
2026-09-23 13:58   ` sashiko-bot
2026-09-23 13:44 ` [PATCH 5/9] media: synopsys: hdmirx: give the signal lock wait a real timeout Sascha Hauer
2026-09-23 13:44 ` [PATCH 6/9] dt-bindings: media: snps,dw-hdmi-rx: make hpd-gpios optional Sascha Hauer
2026-09-23 16:46   ` Conor Dooley
2026-09-24  6:12     ` Sascha Hauer
2026-09-23 13:44 ` [PATCH 7/9] media: synopsys: hdmirx: skip the 5V detect interrupt without a GPIO Sascha Hauer
2026-09-23 13:44 ` [PATCH 8/9] media: v4l2-subdev: notify the bridge when the source power changes Sascha Hauer
2026-09-23 13:44 ` [PATCH 9/9] media: synopsys: hdmirx: get the 5V state from the upstream subdev Sascha Hauer
2026-09-23 14:05   ` sashiko-bot [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=20260923140544.B44771F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --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