From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Dingxian Wen <shawn.wen@rock-chips.com>,
Shreeya Patel <shreeya.patel@collabora.com>,
Gerald Loacker <gerald.loacker@wolfvision.net>,
Lucas Sinn <lucas.sinn@wolfvision.net>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
kernel@collabora.com, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3 01/10] media: synopsys: hdmirx: free the driver data when the last user is gone
Date: Wed, 4 Nov 2026 17:18:36 +0300 [thread overview]
Message-ID: <17cb2a11-9c9d-43c9-889e-8581522c7a74@collabora.com> (raw)
In-Reply-To: <5b3592b1-74b4-43e6-96e8-a600b6fa991c@pengutronix.de>
On 10/16/26 14:06, Sascha Hauer wrote:
> Hi Dmitry,
>
> On 2026-10-07 14:20, Dmitry Osipenko wrote:
>> On 10/5/26 16:28, Sascha Hauer wrote:
>>> @@ -2792,16 +2807,13 @@ static void hdmirx_remove(struct platform_device *pdev)
>>> hdmirx_disable_irq(dev);
>>>
>>> vb2_video_unregister_device(&hdmirx_dev->stream.vdev);
>>> - v4l2_ctrl_handler_free(&hdmirx_dev->hdl);
>>> v4l2_device_unregister(&hdmirx_dev->v4l2_dev);
>>>
>>> - /* touched by hdmirx_disable()->hdmirx_plugout() */
>>> - hdmirx_dev->rgb_range = NULL;
>>> - hdmirx_dev->content_type = NULL;
>>> -
>>> hdmirx_disable(dev);
>>>
>>> reset_control_bulk_assert(HDMIRX_NUM_RST, hdmirx_dev->resets);
>>> +
>>> + v4l2_device_put(&hdmirx_dev->v4l2_dev);
>>> }
>>
>> This is uncommon v4l driver removal pattern, I suspect it's either not
>> correct or needs to be fixed in the core code.
>
> The pattern looks uncommon because many drivers in the tree are affected
> by the same issue ;)
>
> Just like many other drivers the hdmirx embeds a struct v4l2_device in
> its private data struct which is allocated with devm_*, thus freed
> during driver removal. With an opened file descriptor the video_device
> outlives the driver removal, and v4l2_release(), called on
> the last file descriptors close then references the already freed memory
> via vdev->v4l2_dev
>
> This is a long standing problem. See [1] for example for an attempt to
> fix it in the core. It seems consencsus at that time was that it must be
> fixed in the drivers which is what this patch does for the hdmirx.
>
> [1] https://lore.kernel.org/all/20240610100530.1107771-1-sakari.ailus@linux.intel.com/
>
>>
>> What is the user-visible or sanitizer-visible problem? How to reproduce it?
>
> It can be reproduced with Kasan on affected drivers, below on the hdmirx
> driver, but it should be reproducible like this on hantro and others as
> well.
> ...
Thanks, the patches are good to me (tested on 5b with no problems found)
apart from this one that feels like it's not a proper solution.
Will be good to have input from the v4l core maintainers, or have this
fix made separately from the series to not hold rest of the patches.
--
Best regards,
Dmitry
next prev parent reply other threads:[~2026-11-04 14:19 UTC|newest]
Thread overview: 22+ 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-07 11:20 ` Dmitry Osipenko
2026-10-16 11:06 ` Sascha Hauer
2026-11-04 14:18 ` Dmitry Osipenko [this message]
2026-10-05 13:28 ` [PATCH v3 02/10] media: synopsys: hdmirx: add media device infrastructure Sascha Hauer
2026-11-04 14:11 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 03/10] media: synopsys: hdmirx: add media entity for video capture device Sascha Hauer
2026-11-04 14:11 ` Dmitry Osipenko
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-11-04 14:11 ` Dmitry Osipenko
2026-11-04 14:12 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 05/10] media: synopsys: hdmirx: add async subdevice support Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 06/10] media: synopsys: hdmirx: give the signal lock wait a real timeout Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
2026-10-05 13:28 ` [PATCH v3 07/10] media: synopsys: hdmirx: skip the 5V detect interrupt without a GPIO Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
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 13:28 ` [PATCH v3 10/10] media: synopsys: hdmirx: get the 5V state from the upstream subdev Sascha Hauer
2026-11-04 14:12 ` Dmitry Osipenko
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=17cb2a11-9c9d-43c9-889e-8581522c7a74@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gerald.loacker@wolfvision.net \
--cc=hverkuil@kernel.org \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lucas.sinn@wolfvision.net \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawn.wen@rock-chips.com \
--cc=shreeya.patel@collabora.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®