From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A22A739E195 for ; Tue, 3 Feb 2026 13:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770125742; cv=none; b=OJQ1mXABF0Ds/2vsrD9djtLEsm2HfIdHW2KTIwf3k6ROAyvCMZevsFQDe5l5fWiinwmLLJ/bCgCuTdjxwV6MHku0vrVgcd+/0IrCEj34rCItmhm+UKCrdGt7SA2Iv62KEbNVU4jJTBEm4mjW9uutDZz+v4kMnBOdHqhlkh5eWqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770125742; c=relaxed/simple; bh=BxV+Nxst1TqkL5YdN799jIwvEAzBCP2qot9KIk72ymE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KB4WJyxNgf4xNcFj1+rgyrS8i7aZVP1rtxlXqq/GxLj4Rawov9Nvzjl6xAQgnzhzBZCSeC1TnDImw1S2IEpBuo/O6+E2XlvvD+cTPncgkCUM3sa5PwSyxsVRMM9Q2XAB36FDhPRVT9WYNgu9nULN+f9BBlYZmHReZVGNzn6V3jg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=UuWjXHa5; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UuWjXHa5" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0397C1A2B87; Tue, 3 Feb 2026 13:35:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CC64C60728; Tue, 3 Feb 2026 13:35:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3D70B119A8888; Tue, 3 Feb 2026 14:35:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770125736; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=9X4/c3afNW5z4imlA1v5TGJeAloy0wWUIb+4tbtByFA=; b=UuWjXHa53fHUVjL8pw0KR03dFJwO/9nROEdEzMUpA7u11KgqLwGivxH4WnkmUCu7YNu1QM 8699s0aUgQ1YbuRJwKW4v92p2yxFq1N5joFnI9OAHBt0NvE+u4TygvrfgnMu4+PlFYB24j Ml2dA8+9jKfoVJCSOF/1+SuoASmBk+F6SroNI83C4+4KABzl/U0ayQ7Pdz3LSh0xb1YNUF Za+n7ljBVY+fRdQ5QOj83P3MLKcrOB5EsbAMaSAEB4UIidIf+YUx6npd1Q7+Apr91VoHa5 /aXsT+jubba+VPCuHe6VKJrFalSJBOGOk5BjUrDeOnLnFLoSIvBL+55skraGuw== Date: Tue, 3 Feb 2026 14:35:31 +0100 From: Kory Maincent To: Felix Gu Cc: Paul Kocialkowski , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Paul Kocialkowski , 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() Message-ID: <20260203143531.1ab9a19c@kmaincent-XPS-13-7390> In-Reply-To: <20260203105747.71b71dfa@kmaincent-XPS-13-7390> References: <20260130-logicvc_drm-v1-1-04366463750c@gmail.com> <20260203105747.71b71dfa@kmaincent-XPS-13-7390> Organization: bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 On Tue, 3 Feb 2026 10:57:47 +0100 Kory Maincent wrote: > On Fri, 30 Jan 2026 00:21:19 +0800 > Felix Gu wrote: >=20 > > 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. > >=20 > > Fix this by using the __free(device_node) cleanup attribute to automatic > > release the reference when the variable goes out of scope. > >=20 > > Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display controll= er") > > Signed-off-by: Felix Gu > > --- > > drivers/gpu/drm/logicvc/logicvc_drm.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 > > 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 =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; > > =20 > > 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; > > =20 > > - 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"); =20 >=20 > 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) =3D NULL; It seems Linus disagree on this topic and I understand his arguments: https://lore.kernel.org/all/CAHk-=3DwhPZoi03ZwphxiW6cuWPtC3nyKYS8_BThgztCdg= PWP1WA@mail.gmail.com/ https://lore.kernel.org/all/CAHk-=3DwiCOTW5UftUrAnvJkr6769D29tF7Of79gUjdQHS= _TkF5A@mail.gmail.com/ Then, ok to me: Reviewed-by: Kory Maincent Thank you! --=20 K=C3=B6ry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com