lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DEH2BAF6NRPG.3S6GKB2PR1465@bootlin.com>
Date: Mon, 24 Nov 2025 17:23:34 +0100
From: "Luca Ceresoli" <luca.ceresoli@...tlin.com>
To: "Maxime Ripard" <mripard@...nel.org>, "Louis Chauvet"
 <louis.chauvet@...tlin.com>
Cc: "Andrzej Hajda" <andrzej.hajda@...el.com>, "Neil Armstrong"
 <neil.armstrong@...aro.org>, "Robert Foss" <rfoss@...nel.org>, "Laurent
 Pinchart" <Laurent.pinchart@...asonboard.com>, "Jonas Karlman"
 <jonas@...boo.se>, "Jernej Skrabec" <jernej.skrabec@...il.com>, "Maarten
 Lankhorst" <maarten.lankhorst@...ux.intel.com>, "Thomas Zimmermann"
 <tzimmermann@...e.de>, "David Airlie" <airlied@...il.com>, "Simona Vetter"
 <simona@...ll.ch>, "Jonathan Corbet" <corbet@....net>, "Alexey Brodkin"
 <abrodkin@...opsys.com>, "Phong LE" <ple@...libre.com>, "Liu Ying"
 <victor.liu@....com>, "Shawn Guo" <shawnguo@...nel.org>, "Sascha Hauer"
 <s.hauer@...gutronix.de>, "Pengutronix Kernel Team"
 <kernel@...gutronix.de>, "Fabio Estevam" <festevam@...il.com>, "Adrien
 Grassein" <adrien.grassein@...il.com>, "Laurent Pinchart"
 <laurent.pinchart+renesas@...asonboard.com>, "Tomi Valkeinen"
 <tomi.valkeinen+renesas@...asonboard.com>, "Kieran Bingham"
 <kieran.bingham+renesas@...asonboard.com>, "Geert Uytterhoeven"
 <geert+renesas@...der.be>, "Magnus Damm" <magnus.damm@...il.com>, "Kevin
 Hilman" <khilman@...libre.com>, "Jerome Brunet" <jbrunet@...libre.com>,
 "Martin Blumenstingl" <martin.blumenstingl@...glemail.com>, "Chun-Kuang Hu"
 <chunkuang.hu@...nel.org>, "Philipp Zabel" <p.zabel@...gutronix.de>,
 "Matthias Brugger" <matthias.bgg@...il.com>, "AngeloGioacchino Del Regno"
 <angelogioacchino.delregno@...labora.com>, "Anitha Chrisanthus"
 <anitha.chrisanthus@...el.com>, "Edmund Dea" <edmund.j.dea@...el.com>,
 "Inki Dae" <inki.dae@...sung.com>, "Seung-Woo Kim"
 <sw0312.kim@...sung.com>, "Kyungmin Park" <kyungmin.park@...sung.com>,
 "Krzysztof Kozlowski" <krzk@...nel.org>, "Alim Akhtar"
 <alim.akhtar@...sung.com>, "Hui Pu" <Hui.Pu@...ealthcare.com>, "Thomas
 Petazzoni" <thomas.petazzoni@...tlin.com>,
 <dri-devel@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>,
 <linux-doc@...r.kernel.org>, <imx@...ts.linux.dev>,
 <linux-arm-kernel@...ts.infradead.org>,
 <linux-renesas-soc@...r.kernel.org>, <linux-amlogic@...ts.infradead.org>,
 <linux-mediatek@...ts.infradead.org>, <linux-samsung-soc@...r.kernel.org>
Subject: Re: [PATCH 02/26] drm/bridge: deprecate of_drm_find_bridge()

Hi Maxime,

On Mon Nov 24, 2025 at 11:18 AM CET, Maxime Ripard wrote:
> On Wed, Nov 19, 2025 at 02:28:41PM +0000, Louis Chauvet wrote:
>> On 11/19/25 13:05, Luca Ceresoli wrote:
>> > of_drm_find_bridge() does not increment the returned bridge
>> > refcount. drm_of_find_bridge() is to be used as a replacement.
>> >
>> > Suggested-by: Maxime Ripard <mripard@...nel.org>
>> > Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/
>> > Signed-off-by: Luca Ceresoli <luca.ceresoli@...tlin.com>
>> > ---
>> >   drivers/gpu/drm/drm_bridge.c | 7 +++++--
>> >   1 file changed, 5 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
>> > index d98a7b4a83c0..6debbf20aaa8 100644
>> > --- a/drivers/gpu/drm/drm_bridge.c
>> > +++ b/drivers/gpu/drm/drm_bridge.c
>> > @@ -299,7 +299,7 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
>> >    * @bridge: bridge control structure
>> >    *
>> >    * Add the given bridge to the global list of bridges, where they can be
>> > - * found by users via of_drm_find_bridge().
>> > + * found by users via drm_of_find_bridge().
>> >    *
>> >    * The bridge to be added must have been allocated by
>> >    * devm_drm_bridge_alloc().
>> > @@ -360,7 +360,7 @@ EXPORT_SYMBOL(devm_drm_bridge_add);
>> >    * @bridge: bridge control structure
>> >    *
>> >    * Remove the given bridge from the global list of registered bridges, so
>> > - * it won't be found by users via of_drm_find_bridge(), and add it to the
>> > + * it won't be found by users via drm_of_find_bridge(), and add it to the
>> >    * lingering bridge list, to keep track of it until its allocated memory is
>> >    * eventually freed.
>> >    */
>> > @@ -1452,6 +1452,9 @@ EXPORT_SYMBOL(drm_of_find_bridge);
>> >    *
>> >    * @np: device node
>> >    *
>> > + * This function is deprecated. Use drm_of_find_bridge() instead for proper
>> > + * refcounting.
>> > + *
>>
>> I think it should be more explicit that the refcounting is not done by this
>> function, like:
>>
>> 	This function is deprecated. The returned bridge is not refcounted, you
>> should not use drm_bridge_put(). Use drm_of_find_bridge() instead for proper
>> refcounting.
>
> I'd rather say that the callers must take care of the refcounting by
> themselves but that it's racy, or at least that it *must* not use
> drm_bridge_put().

I was rather leaning towards "Deprecated. Convert to drm_of_get_bridge().".

But if we want to still support existing (lazy) users, with yours and
Louis' comments taken into account, what about:

 * This function is deprecated. Convert to of_drm_get_bridge() instead for
 * proper refcounting.
 *
 * The bridge returned by this function is not refcounted. This is
 * dangerous because the bridge might be deallocated even before the caller
 * has a chance to use it. To use this function you have to do one of:
 * - get a reference with drm_bridge_get() as soon as possible to
 *   minimize the race window, and then drm_bridge_put() when no longer
 *   using the pointer
 * - not call drm_bridge_get() or drm_bridge_put() at all, which used to
 *   be the correct practice before dynamic bridge lifetime was introduced
 * - again, convert to of_drm_get_bridge(), which is the only safe thing
 *   to do

Luca

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ