On Fri, Oct 31, 2025 at 06:10:46PM +0100, Raphaël Gallais-Pou wrote:
Le Mon, Sep 22, 2025 at 02:20:12PM +0200, Johan Hovold a écrit :
Make sure to drop the references taken to the vtg devices by of_find_device_by_node() when looking up their driver data during component probe.
Markus suggested “Prevent device leak in of_vtg_find()” as commit summary.
Markus has gotten himself banned from the mailing lists some years ago and even if he is now back with a new mail address most of us still ignore him.
I prefer the Subject as it stands since it captures when the leaks happens, but I don't mind mentioning of_vtg_find() instead if you insist.
Note that holding a reference to a platform device does not prevent its driver data from going away so there is no point in keeping the reference after the lookup helper returns.
Fixes: cc6b741c6f63 ("drm: sti: remove useless fields from vtg structure") Cc: stable@vger.kernel.org # 4.16 Cc: Benjamin Gaignard benjamin.gaignard@collabora.com Signed-off-by: Johan Hovold johan@kernel.org
drivers/gpu/drm/sti/sti_vtg.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c index ee81691b3203..ce6bc7e7b135 100644 --- a/drivers/gpu/drm/sti/sti_vtg.c +++ b/drivers/gpu/drm/sti/sti_vtg.c @@ -143,12 +143,17 @@ struct sti_vtg { struct sti_vtg *of_vtg_find(struct device_node *np) { struct platform_device *pdev;
- struct sti_vtg *vtg;
pdev = of_find_device_by_node(np); if (!pdev) return NULL;
- return (struct sti_vtg *)platform_get_drvdata(pdev);
- vtg = platform_get_drvdata(pdev);
- put_device(&pdev->dev);
I would prefer of_node_put() instead, which does the same basically, but at least it is more obviously linked to of_find_device_by_node().
of_node_put() operates on OF nodes, but here it is the platform device that is leaking.
- return vtg;
}
Johan