public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/bridge/panel: Fix runtime warning on panel bridge release
@ 2024-06-10 10:27 Adam Miotk
  2024-06-10 11:23 ` Maxime Ripard
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Miotk @ 2024-06-10 10:27 UTC (permalink / raw)
  To: dri-devel, linux-kernel
  Cc: Adam Miotk, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Daniel Vetter, Smitha T Murthy, Deepak Pandey

Device managed panel bridge wrappers are created by calling to
drm_panel_bridge_add_typed() and registering a release handler for
clean-up when the device gets unbound.

Since the memory for this bridge is also managed and linked to the panel
device, the release function should not try to free that memory.
Moreover, the call to devm_kfree() inside drm_panel_bridge_remove() will
fail in this case and emit a warning because the panel bridge resource
is no longer on the device resources list (it has been removed from
there before the call to release handlers).

Signed-off-by: Adam Miotk <adam.miotk@arm.com>
---
 drivers/gpu/drm/bridge/panel.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index 32506524d9a2..fe5fb08c9fc4 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -360,9 +360,12 @@ EXPORT_SYMBOL(drm_panel_bridge_set_orientation);
 
 static void devm_drm_panel_bridge_release(struct device *dev, void *res)
 {
-	struct drm_bridge **bridge = res;
+	struct drm_bridge *bridge = *(struct drm_bridge **)res;
 
-	drm_panel_bridge_remove(*bridge);
+	if (!bridge)
+		return;
+
+	drm_bridge_remove(bridge);
 }
 
 /**
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/bridge/panel: Fix runtime warning on panel bridge release
  2024-06-10 10:27 [PATCH] drm/bridge/panel: Fix runtime warning on panel bridge release Adam Miotk
@ 2024-06-10 11:23 ` Maxime Ripard
  0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2024-06-10 11:23 UTC (permalink / raw)
  To: Adam Miotk
  Cc: dri-devel, linux-kernel, Andrzej Hajda, Neil Armstrong,
	Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Thomas Zimmermann, David Airlie, Daniel Vetter,
	Smitha T Murthy, Deepak Pandey

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]

On Mon, Jun 10, 2024 at 11:27:39AM GMT, Adam Miotk wrote:
> Device managed panel bridge wrappers are created by calling to
> drm_panel_bridge_add_typed() and registering a release handler for
> clean-up when the device gets unbound.
> 
> Since the memory for this bridge is also managed and linked to the panel
> device, the release function should not try to free that memory.
> Moreover, the call to devm_kfree() inside drm_panel_bridge_remove() will
> fail in this case and emit a warning because the panel bridge resource
> is no longer on the device resources list (it has been removed from
> there before the call to release handlers).
> 
> Signed-off-by: Adam Miotk <adam.miotk@arm.com>

I've added a Fixes tag and applied to drm-misc-fixes, thanks!
Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-10 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10 10:27 [PATCH] drm/bridge/panel: Fix runtime warning on panel bridge release Adam Miotk
2024-06-10 11:23 ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox