| Message ID | 20260713-drm_refcount_wiring-v2-0-d3bb61f4bd4d@redhat.com (mailing list archive) |
|---|---|
| Headers |
Return-Path: <linux-sunxi+bounces-24385-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 418341C2B71 for <noreply@patchwork.local>; Mon, 13 Jul 2026 13:53:53 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=redhat.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-24385-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-24385-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 9475F30264D0 for <noreply@patchwork.local>; Mon, 13 Jul 2026 11:53:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6286C37C936; Mon, 13 Jul 2026 11:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ahPEPnV8" X-Original-To: linux-sunxi@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 D5C193F44C0 for <linux-sunxi@lists.linux.dev>; Mon, 13 Jul 2026 11:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783943627; cv=none; b=d5wCkpdOWOrVzJvnTJxKvZSBpC0z9RFXrvpjpmYXs05MpSeHUeNs4lMleWGU+1CGXdPSIqYnXd2qF1cK2qk5jwN/amDEft2Ufl1mSgXfE3FBeBPZrXynN6OTn3m8ztqQTVxw5/4NUk5sefuLVdl3r6REscoVmP4616LbSJQ91T8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783943627; c=relaxed/simple; bh=SRtXo7qoSqgK5l+umf1rMmWNg22khBPItUlyntwmvA0=; h=From:Subject:Date:Message-Id:MIME-Version:To:Cc:Content-Type; b=uYKhawrNnGX59T3BLoEcr1PCXvgOYewygGeKrVtuFCRjHUlXidgqgZ1oKrpCIAQvTY8W8iJ9X75dOteK6hQLAmStgXwCQ863qUKzlxy/Cd5uWBcxletF22lYIpMemDXCbkjYdcpkh//kBn426mE6SLRv8Z42yTWE8LK+Q5ayTPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ahPEPnV8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783943625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B54XxYOgQOiIEJK7sD0ym83+/MGWSHFF64vmz3jQu+o=; b=ahPEPnV8zcddpMKlIS6pb+xp30RpF7wNgpA3bTIjmri6TQAfXvaGq7YlCnpe81E7m0pRb9 v+I0+/2PFQESwDzyuQIgFTIc1LQi1ARBkduHG/CQhqP8ku6fX4/jR+3taMGOvUCvBpJbz5 Rp8/A7uGgVPJmBRHPmdKw4EHZ2XtScA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-572-Dn27GUPQMfSOFm3Mg7PNRQ-1; Mon, 13 Jul 2026 07:53:41 -0400 X-MC-Unique: Dn27GUPQMfSOFm3Mg7PNRQ-1 X-Mimecast-MFC-AGG-ID: Dn27GUPQMfSOFm3Mg7PNRQ_1783943616 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CA9E61955D91; Mon, 13 Jul 2026 11:53:33 +0000 (UTC) Received: from [192.168.1.153] (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0CB6118005A0; Mon, 13 Jul 2026 11:53:14 +0000 (UTC) From: Albert Esteve <aesteve@redhat.com> Subject: [PATCH v2 0/5] drm/panel: refcounting panel lookups and references Date: Mon, 13 Jul 2026 13:53:03 +0200 Message-Id: <20260713-drm_refcount_wiring-v2-0-d3bb61f4bd4d@redhat.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/22NzQ6CMBCEX8Xs2Zq2/DR68j0MIaVdYA+0ZouoI by7Fa8ev8nMNyskZMIEl8MKjAsliiGDPh7AjTYMKMhnBi11LStVCM9Ty9i7+Ahz+ySmMIgSKzS VwbMsDeTlPRfotVtvTeaR0hz5vZ8s6pv+fLWu//oWJaRwzipruqLz2F8Z/Wjnk4sTNNu2fQCw2 Q5NtwAAAA== X-Change-ID: 20260513-drm_refcount_wiring-4e5e757e9047 To: Neil Armstrong <neil.armstrong@linaro.org>, Jessica Zhang <jesszhan0024@gmail.com>, 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>, Andrzej Hajda <andrzej.hajda@intel.com>, Robert Foss <rfoss@kernel.org>, Laurent Pinchart <Laurent.pinchart@ideasonboard.com>, Jonas Karlman <jonas@kwiboo.se>, Jernej Skrabec <jernej.skrabec@gmail.com>, Luca Ceresoli <luca.ceresoli@bootlin.com>, Inki Dae <inki.dae@samsung.com>, Jagan Teki <jagan@amarulasolutions.com>, Marek Szyprowski <m.szyprowski@samsung.com>, Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>, Lucas Stach <l.stach@pengutronix.de>, Frank Li <Frank.Li@nxp.com>, Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix Kernel Team <kernel@pengutronix.de>, Fabio Estevam <festevam@gmail.com>, Paul Cercueil <paul@crapouillou.net>, Linus Walleij <linusw@kernel.org>, Marek Vasut <marex@denx.de>, Stefan Agner <stefan@agner.ch>, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>, Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>, Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>, Geert Uytterhoeven <geert+renesas@glider.be>, Magnus Damm <magnus.damm@gmail.com>, Biju Das <biju.das.jz@bp.renesas.com>, Sandy Huang <hjc@rock-chips.com>, =?utf-8?q?Heiko_St=C3=BCbner?= <heiko@sntech.de>, Andy Yan <andy.yan@rock-chips.com>, Yannick Fertre <yannick.fertre@foss.st.com>, Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>, Philippe Cornu <philippe.cornu@foss.st.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Chen-Yu Tsai <wens@kernel.org>, Samuel Holland <samuel@sholland.org>, Jyri Sarha <jyri.sarha@iki.fi>, Jingoo Han <jingoohan1@gmail.com>, Seung-Woo Kim <sw0312.kim@samsung.com>, Kyungmin Park <kyungmin.park@samsung.com>, Krzysztof Kozlowski <krzk@kernel.org>, Peter Griffin <peter.griffin@linaro.org>, Alim Akhtar <alim.akhtar@samsung.com>, Alison Wang <alison.wang@nxp.com>, Paul Kocialkowski <paulk@sys-base.io>, Alain Volmat <alain.volmat@foss.st.com>, Raphael Gallais-Pou <rgallaispou@gmail.com>, Thierry Reding <thierry.reding@kernel.org>, Mikko Perttunen <mperttunen@nvidia.com>, Jonathan Hunter <jonathanh@nvidia.com> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, Albert Esteve <aesteve@redhat.com> X-Developer-Signature: v=1; a=ed25519-sha256; t=1783943594; l=5435; i=aesteve@redhat.com; s=20260303; h=from:subject:message-id; bh=SRtXo7qoSqgK5l+umf1rMmWNg22khBPItUlyntwmvA0=; b=krKLhcYOsELwWzp4Mkmstg1CoAIW+2iQNP5Bx9vPTWdaJHFoUApmueGaj5CJ94aMN2hbmSM4Z i48STMH6Q1GA5qfKEcIhF79Cp9o+131NV2sOs0w0IemF64ja2dO5wAc X-Developer-Key: i=aesteve@redhat.com; a=ed25519; pk=YSFz6sOHd2L45+Fr8DIvHTi6lSIjhLZ5T+rkxspJt1s= X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Wcr4GxJeB53M5SoKjoJzl-oQoyyHx9mZBu5LOd7fb7k_1783943616 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
drm/panel: refcounting panel lookups and references
|
|
Message
Albert Esteve
July 13, 2026, 11:53 a.m. UTC
The drm_panel subsystem provides kref-based reference counting [1]
(drm_panel_get/put) but almost nothing in the tree actually uses it.
This results in a systemic use-after-free pattern throughout the codebase.
This series aims to close all those issues.
Patches 1-2: fix the infrastructure. drm_panel_add/remove now keep
a counted reference for the list entry. drm_panel_bridge_add_typed()
now holds a counted reference for the lifetime of the panel_bridge.
Patch 3: change the semantics of of_drm_find_panel(). It now acquires
a reference before returning, under panel_lock. All in-tree callers
of of_drm_find_panel() and drm_of_find_panel_or_bridge() are updated.
Two patterns are common in these fixes:
- Bridge-wrapping: the panel is passed to devm_drm_panel_bridge_add()
or equivalent, which acquires its own reference. The caller (including
devm_drm_of_get_bridge() and drmm_of_get_bridge()) releases its lookup
reference immediately after.
- Store-and-use: the panel pointer is kept in a driver struct and
used directly for the device lifetime. The reference is released in the
remove/unbind path, or via devm_add_action_or_reset() where no explicit
teardown function exists.
Patch 4: extend the same fix to find_panel_by_fwnode(), a static helper
used internally by drm_panel_add_follower(). Since it has no external
callers, the fix is self-contained: drm_panel_remove_follower() is
updated to call drm_panel_put() to balance the reference.
Patch 5: update a remaining batch of drivers calling of_drm_find_panel()
or drm_of_find_panel_or_bridge() to release the reference after wrapping
the panel in a bridge or on error paths.
In order to catch all places in the tree that required releasing the
reference, the search was assisted by an AI model. Specifically, a
Coccinelle script was designed by the agent to address the trivial changes
(not included in the series). Although a few required manual fixes, with goto
labels or bracket additions. Additionally, the model helped to discern implicit
teardown paths that were addressed with devm_add_action_or_reset() calls.
Thus, these commits have the Assisted-by label following the project guidelines.
No functional change is intended for any driver. The reference
counting only affects object lifetime; panel operations are unaffected.
[1] https://lore.kernel.org/all/20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com/
Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
Changes in v2:
- Squash of_drm_find_panel() API change with its caller fixes
- Split find_panel_by_fwnode() into its own commit
- Update kernel-doc for drm_of_find_panel_or_bridge()
- Link to v1: https://lore.kernel.org/r/20260626-drm_refcount_wiring-v1-0-cca1a7b3bdef@redhat.com
---
Albert Esteve (5):
drm/panel: have drm_panel_add/remove manage a list reference
drm/bridge/panel: hold a reference to the wrapped panel
drm/panel: of_drm_find_panel() return a counted reference
drm/panel: find_panel_by_fwnode() return a counted reference
drm: release panel reference after panel bridge creation
drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +++
drivers/gpu/drm/bridge/panel.c | 18 ++++++++++++----
drivers/gpu/drm/drm_of.c | 3 ++-
drivers/gpu/drm/drm_panel.c | 24 +++++++++++++++++-----
drivers/gpu/drm/exynos/exynos_dp.c | 10 +++++++++
drivers/gpu/drm/exynos/exynos_drm_dpi.c | 3 +++
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 18 ++++++++++++++++
drivers/gpu/drm/imx/dcss/dcss-kms.c | 3 +++
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 4 +++-
drivers/gpu/drm/logicvc/logicvc_interface.c | 12 +++++++++++
drivers/gpu/drm/mcde/mcde_drv.c | 1 +
drivers/gpu/drm/mcde/mcde_dsi.c | 1 +
drivers/gpu/drm/mxsfb/mxsfb_drv.c | 1 +
drivers/gpu/drm/omapdrm/dss/output.c | 1 +
drivers/gpu/drm/pl111/pl111_drv.c | 1 +
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 1 +
drivers/gpu/drm/renesas/rcar-du/rcar_lvds.c | 1 +
drivers/gpu/drm/renesas/rz-du/rzg2l_du_encoder.c | 1 +
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 11 ++++++++++
drivers/gpu/drm/rockchip/rockchip_lvds.c | 1 +
drivers/gpu/drm/rockchip/rockchip_rgb.c | 1 +
drivers/gpu/drm/sti/sti_dvo.c | 3 +++
drivers/gpu/drm/stm/ltdc.c | 1 +
drivers/gpu/drm/stm/lvds.c | 3 +++
drivers/gpu/drm/sun4i/sun4i_lvds.c | 13 ++++++++++++
drivers/gpu/drm/sun4i/sun4i_rgb.c | 13 ++++++++++++
drivers/gpu/drm/sun4i/sun4i_tcon.c | 2 ++
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 2 ++
drivers/gpu/drm/tegra/dsi.c | 1 +
drivers/gpu/drm/tegra/output.c | 3 +++
drivers/gpu/drm/tidss/tidss_kms.c | 16 ++++++++++-----
drivers/gpu/drm/tve200/tve200_drv.c | 1 +
32 files changed, 161 insertions(+), 16 deletions(-)
---
base-commit: 502d801f0ab03e4f32f9a33d203154ce84887921
change-id: 20260513-drm_refcount_wiring-4e5e757e9047
Best regards,