From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8EFAE87851 for ; Tue, 3 Feb 2026 17:51:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A53910E326; Tue, 3 Feb 2026 17:51:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="otFZ80fj"; dkim-atps=neutral Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8C6F610E326 for ; Tue, 3 Feb 2026 17:51:54 +0000 (UTC) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id BC74C4E423E4; Tue, 3 Feb 2026 17:51:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8C41760728; Tue, 3 Feb 2026 17:51:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D4AAB119A8888; Tue, 3 Feb 2026 18:51:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770141111; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=1xdZ/OSFUvAxKiBQgdcMhIY4/A3/12i5aPJKLBIc3FQ=; b=otFZ80fjX9UqRfcI9+MjBeKuolSOj6WASNsmJaNDZamNVbA4JHcEtRFVo0cTwme3yxqTWi e+4iy5M40vGHjfyxzGrIuadsekZif2cu5URUkrx5oI2YPtS3xIFPN4KV28SpB4OKtFy3iJ /JnZxBHwZtk5hRMD9hARxjXsdqp5Vgfnij8D4q7/4T5iEv0VOfBLnmnFVVudR0QXICdm3c OwnLlpssyqWD/17FLm26TwvXGX6MakxtuibOI+N+E1bzFvLVZDxmSnzIz1Oc4U58A3GkkS hFCHHV24hkxzjnXqmSiaA6HHqU3kB1MQ66kCK8CRHMCm9ALJqg2+UV8EIAFaxg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 03 Feb 2026 18:51:47 +0100 Message-Id: Subject: Re: [PATCH] drm/logicvc: Fix device node reference leak in logicvc_drm_config_parse() Cc: "Paul Kocialkowski" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Paul Kocialkowski" , , To: "Kory Maincent" , "Felix Gu" From: "Luca Ceresoli" X-Mailer: aerc 0.20.1 References: <20260130-logicvc_drm-v1-1-04366463750c@gmail.com> <20260203105747.71b71dfa@kmaincent-XPS-13-7390> <20260203143531.1ab9a19c@kmaincent-XPS-13-7390> In-Reply-To: <20260203143531.1ab9a19c@kmaincent-XPS-13-7390> X-Last-TLS-Session-Version: TLSv1.3 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue Feb 3, 2026 at 2:35 PM CET, Kory Maincent wrote: > On Tue, 3 Feb 2026 10:57:47 +0100 > Kory Maincent wrote: > >> On Fri, 30 Jan 2026 00:21:19 +0800 >> Felix Gu wrote: >> >> > The logicvc_drm_config_parse() function calls of_get_child_by_name() t= o >> > 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 automat= ic >> > release the reference when the variable goes out of scope. >> > >> > Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display control= ler") >> > Signed-off-by: Felix Gu >> > --- >> > 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..bbebf4fc7f= 51 >> > 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_d= rm >> > *logicvc) struct device *dev =3D drm_dev->dev; >> > struct device_node *of_node =3D dev->of_node; >> > struct logicvc_drm_config *config =3D &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 =3D of_get_child_by_name(of_node, "layers"); >> > + struct device_node *layers_node __free(device_node) =3D >> > + 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 thi= s: >> struct device_node *layers_node __free(device_node) =3D NULL; > > It seems Linus disagree on this topic and I understand his arguments: > https://lore.kernel.org/all/CAHk-=3DwhPZoi03ZwphxiW6cuWPtC3nyKYS8_BThgztC= dgPWP1WA@mail.gmail.com/ > https://lore.kernel.org/all/CAHk-=3DwiCOTW5UftUrAnvJkr6769D29tF7Of79gUjdQ= HS_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 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