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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EFC43C4452A for ; Mon, 20 Jul 2026 13:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:From:To:Cc: Subject:Message-Id:Date:Mime-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hmtBDCMJrqi0+JQj/Zm5/m04BsBnLbcE/sV+7+jKjUM=; b=AQS8nmaIBjLtF5 KTYAl4nISBNoJQWpqLpcU7gH8DYd13vGXaqu1QDXonnUsxEPUC/p5N3Hv/9phKm4Di8eQBpauiaeT rpiUGmnJ4KjI115FRbLJwkSksTog0AC5xbbI+T1Wfxcp0RZsxvtZ8yE35ldy5pzYzRyBGIQIoqeV7 7BAsqKtJRFBKy7K8qkF4o2ji1OXqD0d/7+bXe2EhKihNQ9zHPygIDmqwqjs6Czrp7SOcgx3hSHcwZ 8KfRjxeV12gCr0kAbWm7HtXXG6gZfd4iwjMmi4rKTBURrCO/xPlLbtmJUcd7z/Fdj1R0PAuQbt4G0 E0DkFdF0O/eNeLvXD3gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wlnoh-00000006lpS-3Nfx; Mon, 20 Jul 2026 13:13:55 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wlnof-00000006loj-2bq4 for linux-rockchip@lists.infradead.org; Mon, 20 Jul 2026 13:13:55 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 1170D1A1112; Mon, 20 Jul 2026 13:13:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CDAB860363; Mon, 20 Jul 2026 13:13:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9AF1D11BD14B3; Mon, 20 Jul 2026 15:13:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784553228; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=lB7WXUeDy7/vdkEKe1OOBE05FF1zuq4aESv2R41btZY=; b=0lIAXfW6SBEjFIbgS53IC0goRA2iHo2+WqOIKxAIkpMCF5A9llJT8IVLG8gMZunsWx2Jpk fBGDgRtlWCT0DXkGGMaYVyYsPemx1KV9MyCuNgTj6mqsRLddDen3VfR6HZAxfcQcSHaHrI KIXXK8vBzpdzJ9eDtXPsJToqXGGCQvVfyevHqYIIiVV2VIZSdlshtS6bmCkqbitWkxgPNS zX1qzsTd/ZIJCJvBvEEvlT6uK52ZTK/97iAqrtVF9OmF96ofFMpeAJrxerQ39Hg2s4tML0 xMrIrW1fnoyCYr4ON5TN3PP6PoznMwK+eIKWaqp0ugbwgWJYA2t7T8GKGMbhQQ== Mime-Version: 1.0 Date: Mon, 20 Jul 2026 15:13:28 +0200 Message-Id: Subject: Re: [PATCH v3 4/4] drm/panel: find_panel_by_fwnode() return a counted reference Cc: , , , , , , , , , , To: "Albert Esteve" , "Neil Armstrong" , "Jessica Zhang" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Andrzej Hajda" , "Robert Foss" , "Laurent Pinchart" , "Jonas Karlman" , "Jernej Skrabec" , "Luca Ceresoli" , "Inki Dae" , "Jagan Teki" , "Marek Szyprowski" , "Laurentiu Palcu" , "Lucas Stach" , "Frank Li" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "Paul Cercueil" , "Linus Walleij" , "Marek Vasut" , "Stefan Agner" , "Tomi Valkeinen" , "Laurent Pinchart" , "Kieran Bingham" , "Geert Uytterhoeven" , "Magnus Damm" , "Biju Das" , "Sandy Huang" , =?utf-8?q?Heiko_St=C3=BCbner?= , "Andy Yan" , "Yannick Fertre" , "Raphael Gallais-Pou" , "Philippe Cornu" , "Maxime Coquelin" , "Alexandre Torgue" , "Chen-Yu Tsai" , "Samuel Holland" , "Jyri Sarha" , "Jingoo Han" , "Seung-Woo Kim" , "Kyungmin Park" , "Krzysztof Kozlowski" , "Peter Griffin" , "Alim Akhtar" , "Alison Wang" , "Paul Kocialkowski" , "Alain Volmat" , "Raphael Gallais-Pou" , "Thierry Reding" , "Mikko Perttunen" , "Jonathan Hunter" From: "Luca Ceresoli" X-Mailer: aerc 0.21.0 References: <20260717-drm_refcount_wiring-v3-0-023900c32e01@redhat.com> <20260717-drm_refcount_wiring-v3-4-023900c32e01@redhat.com> In-Reply-To: <20260717-drm_refcount_wiring-v3-4-023900c32e01@redhat.com> X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260720_061353_801923_8D07177F X-CRM114-Status: GOOD ( 19.01 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Hello Albert, On Fri Jul 17, 2026 at 4:02 PM CEST, Albert Esteve wrote: > find_panel_by_fwnode() is the fwnode-based counterpart to > of_drm_find_panel(), used internally by drm_panel_add_follower(). > Like of_drm_find_panel(), it returned an unrefcounted pointer, > leaving a window where the panel could be freed between the lookup > and first use. > > drm_panel_add_follower() worked around the missing panel kref by > calling get_device() on the panel's underlying struct device. > However, get_device() only prevents the device kobject from being freed. > It does not prevent the panel's kzalloc()'d container memory from being > released when the kref reaches zero. > > Apply the same fix: call drm_panel_get() under panel_lock before > returning. Since find_panel_by_fwnode() now transfers a counted > reference to drm_panel_add_follower(), drm_panel_remove_follower() > must balance it with a matching drm_panel_put(). > > Acked-by: Maxime Ripard > Signed-off-by: Albert Esteve > --- > drivers/gpu/drm/drm_panel.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c > index 72cf86253c0cd..a00ae98ed0956 100644 > --- a/drivers/gpu/drm/drm_panel.c > +++ b/drivers/gpu/drm/drm_panel.c > @@ -542,7 +542,13 @@ int of_drm_get_panel_orientation(const struct device_node *np, > EXPORT_SYMBOL(of_drm_get_panel_orientation); > #endif > > -/* Find panel by fwnode. This should be identical to of_drm_find_panel(). */ > +/* > + * Find panel by fwnode, returning a counted reference. > + * > + * Behaves identically to of_drm_find_panel(). On success the returned > + * pointer has been passed through drm_panel_get(); the caller must call > + * drm_panel_put() when done with it. > + */ > static struct drm_panel *find_panel_by_fwnode(const struct fwnode_handle *fwnode) > { > struct drm_panel *panel; > @@ -554,6 +560,7 @@ static struct drm_panel *find_panel_by_fwnode(const struct fwnode_handle *fwnode > > list_for_each_entry(panel, &panel_list, list) { > if (dev_fwnode(panel->dev) == fwnode) { > + drm_panel_get(panel); > mutex_unlock(&panel_lock); > return panel; > } > @@ -690,6 +697,7 @@ void drm_panel_remove_follower(struct drm_panel_follower *follower) > mutex_unlock(&panel->follower_lock); > > put_device(panel->dev); > + drm_panel_put(panel); Based on your description, can we drop the get_device/put_device() now? That can be done as a future cleanup, so: Reviewed-by: Luca Ceresoli Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip