stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Raphaël Gallais-Pou" <rgallaispou@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Johan Hovold <johan@kernel.org>,
	dri-devel@lists.freedesktop.org, stable@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Alain Volmat <alain.volmat@foss.st.com>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	David Airlie <airlied@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Simona Vetter <simona@ffwll.ch>,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: [PATCH] drm: sti: fix device leaks at component probe
Date: Mon, 3 Nov 2025 19:56:55 +0100	[thread overview]
Message-ID: <aQj69wzTceDklx2Y@thinkstation> (raw)
In-Reply-To: <d1c2e56b-2ef9-4ab1-a4f8-3834d1857386@web.de>

Le Mon, Sep 22, 2025 at 06:16:47PM +0200, Markus Elfring a écrit :
> > Make sure to drop the references taken to the vtg devices by
> 
>                                                 VTG device?

Video Timing Generator.  This IP creates a vsync pulse and synchonize
the components together.

> 
> 
> > of_find_device_by_node() when looking up their driver data during
> > component probe.
> …
> 
> How do you think about to increase the application of scope-based resource management?
> https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/device.h#L1180

Oh... I wasn't aware of this.  FWIU it is a way to directly free an
allocated memory whenever a variable goes out of scope using the cleanup
attribute.

IMO this is also a clever solution to prevent the memory leak, and it
would be a shorter patch.  So basically, instead of calling put_device()
as Johan did, you would suggest something like this ?

diff --git i/drivers/gpu/drm/sti/sti_vtg.c w/drivers/gpu/drm/sti/sti_vtg.c
index ee81691b3203..5193196d9291 100644
--- i/drivers/gpu/drm/sti/sti_vtg.c
+++ w/drivers/gpu/drm/sti/sti_vtg.c
@@ -142,7 +142,7 @@ struct sti_vtg {

 struct sti_vtg *of_vtg_find(struct device_node *np)
 {
-       struct platform_device *pdev;
+       struct platform_device *pdev __free(put_device) = NULL;

Best regards,
Raphaël


> 
> Can a summary phrase like “Prevent device leak in of_vtg_find()” be nicer?
> 
> Regards,
> Markus

  reply	other threads:[~2025-11-03 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-22 12:20 [PATCH] drm: sti: fix device leaks at component probe Johan Hovold
2025-09-22 16:16 ` Markus Elfring
2025-11-03 18:56   ` Raphaël Gallais-Pou [this message]
2025-11-04  8:00     ` Markus Elfring
2025-11-04 11:25     ` Johan Hovold
2025-10-27 13:35 ` Johan Hovold
2025-10-31 17:10 ` Raphaël Gallais-Pou
2025-11-04 11:21   ` Johan Hovold

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=aQj69wzTceDklx2Y@thinkstation \
    --to=rgallaispou@gmail.com \
    --cc=Markus.Elfring@web.de \
    --cc=airlied@gmail.com \
    --cc=alain.volmat@foss.st.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).