All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Kory Maincent" <kory.maincent@bootlin.com>,
	"Felix Gu" <ustc.gu@gmail.com>
Cc: "Paul Kocialkowski" <paulk@sys-base.io>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Paul Kocialkowski" <paul.kocialkowski@bootlin.com>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/logicvc: Fix device node reference leak in logicvc_drm_config_parse()
Date: Tue, 03 Feb 2026 18:51:47 +0100	[thread overview]
Message-ID: <DG5INIQWWPJV.31PV8URRWUZF6@bootlin.com> (raw)
In-Reply-To: <20260203143531.1ab9a19c@kmaincent-XPS-13-7390>

On Tue Feb 3, 2026 at 2:35 PM CET, Kory Maincent wrote:
> On Tue, 3 Feb 2026 10:57:47 +0100
> Kory Maincent <kory.maincent@bootlin.com> wrote:
>
>> On Fri, 30 Jan 2026 00:21:19 +0800
>> Felix Gu <ustc.gu@gmail.com> wrote:
>>
>> > The logicvc_drm_config_parse() function calls of_get_child_by_name() to
>> > find the "layers" node but fails to release the reference, leading to a
>> > device node reference leak.
>> >
>> > Fix this by using the __free(device_node) cleanup attribute to automatic
>> > release the reference when the variable goes out of scope.
>> >
>> > Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display controller")
>> > Signed-off-by: Felix Gu <ustc.gu@gmail.com>
>> > ---
>> >  drivers/gpu/drm/logicvc/logicvc_drm.c | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/logicvc/logicvc_drm.c
>> > b/drivers/gpu/drm/logicvc/logicvc_drm.c index 204b0fee55d0..bbebf4fc7f51
>> > 100644 --- a/drivers/gpu/drm/logicvc/logicvc_drm.c
>> > +++ b/drivers/gpu/drm/logicvc/logicvc_drm.c
>> > @@ -92,7 +92,6 @@ static int logicvc_drm_config_parse(struct logicvc_drm
>> > *logicvc) struct device *dev = drm_dev->dev;
>> >  	struct device_node *of_node = dev->of_node;
>> >  	struct logicvc_drm_config *config = &logicvc->config;
>> > -	struct device_node *layers_node;
>> >  	int ret;
>> >
>> >  	logicvc_of_property_parse_bool(of_node,
>> > LOGICVC_OF_PROPERTY_DITHERING, @@ -128,7 +127,8 @@ static int
>> > logicvc_drm_config_parse(struct logicvc_drm *logicvc) if (ret)
>> >  		return ret;
>> >
>> > -	layers_node = of_get_child_by_name(of_node, "layers");
>> > +	struct device_node *layers_node __free(device_node) =
>> > +		of_get_child_by_name(of_node, "layers");
>>
>> We usualy don't declare variable in the middle of a function.
>> You should rather simply change the declaration line at the top like this:
>> struct device_node *layers_node __free(device_node) = NULL;
>
> It seems Linus disagree on this topic and I understand his arguments:
> https://lore.kernel.org/all/CAHk-=whPZoi03ZwphxiW6cuWPtC3nyKYS8_BThgztCdgPWP1WA@mail.gmail.com/
> https://lore.kernel.org/all/CAHk-=wiCOTW5UftUrAnvJkr6769D29tF7Of79gUjdQHS_TkF5A@mail.gmail.com/

I agree it makes code much more readable, espacially in the case of cleanup
actions.

> Then, ok to me:
> Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>

Thanks! I'm applying this patch to drm-misc-fixes perhaps next week.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2026-02-03 17:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 16:21 [PATCH] drm/logicvc: Fix device node reference leak in logicvc_drm_config_parse() Felix Gu
2026-01-29 22:01 ` Luca Ceresoli
2026-02-03  9:57 ` Kory Maincent
2026-02-03 13:35   ` Kory Maincent
2026-02-03 17:51     ` Luca Ceresoli [this message]
2026-02-10 16:44 ` Luca Ceresoli

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=DG5INIQWWPJV.31PV8URRWUZF6@bootlin.com \
    --to=luca.ceresoli@bootlin.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kory.maincent@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=paulk@sys-base.io \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=ustc.gu@gmail.com \
    /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.