From: sashiko-bot@kernel.org
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v3 01/10] media: synopsys: hdmirx: free the driver data when the last user is gone
Date: Mon, 05 Oct 2026 13:43:31 +0000 [thread overview]
Message-ID: <20261005134331.8B1361F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261005-hdmirx-media-v3-1-71a11a2e3e76@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] media: hdmirx: Use-After-Free of resets array during devres cleanup
--
commit e1b26e1980a2a31fc0b4801e98e60468eba4a502
Author: Sascha Hauer <s.hauer@pengutronix.de>
media: synopsys: hdmirx: free the driver data when the last user is gone
The driver data is allocated with devm_kzalloc() and contains the
video_device, the vb2 queue and the control handler. devres frees it when
the device is unbound, but an open file descriptor on the video device
node keeps the video_device referenced beyond that point.
> diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> index 25f8ca0d6d946..bc541431638e7 100644
> --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
[ ... ]
> @@ -2646,6 +2642,16 @@ static int hdmirx_register_cec(struct snps_hdmirx_dev *hdmirx_dev,
> return 0;
> }
>
> +/* Runs when the last user of a device node is gone, possibly after remove() */
> +static void hdmirx_v4l2_release(struct v4l2_device *v4l2_dev)
> +{
> + struct snps_hdmirx_dev *hdmirx_dev =
> + container_of(v4l2_dev, struct snps_hdmirx_dev, v4l2_dev);
> +
> + v4l2_ctrl_handler_free(&hdmirx_dev->hdl);
> + kfree(hdmirx_dev);
^^^^
[Severity: High]
hdmirx_parse_dt() calls devm_reset_control_bulk_get_exclusive(), which
registers a devres action that stores the pointer to the inline array
hdmirx_dev->resets.
When the last v4l2 user is gone, this kfree(hdmirx_dev) frees the driver
data structure synchronously. The driver core will later invoke
devres_release_all(), which calls devm_reset_control_bulk_release(). That
release function will attempt to iterate and put the resets using the
stored pointer, which now points into the already freed hdmirx_dev.
Does this code cause a use-after-free during devres cleanup?
> +}
> +
> static int hdmirx_probe(struct platform_device *pdev)
> {
> struct snps_hdmirx_dev *hdmirx_dev;
[ ... ]
> @@ -2771,10 +2780,16 @@ static int hdmirx_probe(struct platform_device *pdev)
> vb2_video_unregister_device(&hdmirx_dev->stream.vdev);
> err_unreg_v4l2_dev:
> v4l2_device_unregister(&hdmirx_dev->v4l2_dev);
> -err_hdl:
> - v4l2_ctrl_handler_free(&hdmirx_dev->hdl);
> + hdmirx_disable(dev);
> + v4l2_device_put(&hdmirx_dev->v4l2_dev);
> +
> + return ret;
> +
> err_pm:
> hdmirx_disable(dev);
> + v4l2_ctrl_handler_free(&hdmirx_dev->hdl);
> +err_free:
> + kfree(hdmirx_dev);
^^^^
[Severity: High]
If probe fails after hdmirx_parse_dt() has successfully called
devm_reset_control_bulk_get_exclusive(), hdmirx_dev is explicitly freed
here. Once probe returns, the driver core will run devres cleanup.
Does this error path result in the same use-after-free when accessing
hdmirx_dev->resets?
>
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261005-hdmirx-media-v3-0-71a11a2e3e76@pengutronix.de?part=1
next prev parent reply other threads:[~2026-10-05 13:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 13:28 [PATCH v3 00/10] media: synopsys: hdmirx: support an HDMI bridge in front of the receiver Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 01/10] media: synopsys: hdmirx: free the driver data when the last user is gone Sascha Hauer
2026-10-05 13:43 ` sashiko-bot [this message]
2026-10-07 11:20 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 02/10] media: synopsys: hdmirx: add media device infrastructure Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 03/10] media: synopsys: hdmirx: add media entity for video capture device Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 04/10] dt-bindings: media: snps,dw-hdmi-rx: add a port for a bridge in front Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 05/10] media: synopsys: hdmirx: add async subdevice support Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 06/10] media: synopsys: hdmirx: give the signal lock wait a real timeout Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 07/10] media: synopsys: hdmirx: skip the 5V detect interrupt without a GPIO Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 08/10] media: v4l2-device: wait for notifications when unregistering a subdev Sascha Hauer
2026-10-05 13:28 ` [PATCH v3 09/10] media: v4l2-subdev: notify the bridge when the source power changes Sascha Hauer
2026-10-05 14:02 ` sashiko-bot
2026-10-05 13:28 ` [PATCH v3 10/10] media: synopsys: hdmirx: get the 5V state from the upstream subdev Sascha Hauer
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=20261005134331.8B1361F000FF@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 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.