Re: [PATCH v3 01/10] media: synopsys: hdmirx: free the driver data when the last user is gone
From: Sascha Hauer
Date: Mon Nov 16 2026 - 10:10:43 EST
Hi Hans,
On 2026-11-13 09:44, Hans Verkuil wrote:
> >> 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@xxxxxxxxxxxxxxx/
> >>
> >>>
> >>> 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.
> >
>
> There are two possible options a driver can use: if the driver has just a single
> video device that it registers, then it can use the release callback of the
> video_device to do the cleanup. If there are multiple video_device structs, then
> the release callback of v4l2_device can be used.
>
> Using the release callback of v4l2_device is the more generic option, so this
> is fine.
>
> Many older v4l2 drivers do this wrong, mostly due to a poor understanding of
> how this worked among media developers at the time.
>
> In any case, I'll take this patch. It's good.
I just realized this patches a Use after free. I just sent a patch
fixing it to the list.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |