Skip to contentSkip to conversation

drm/bridge/panel: Fix runtime warning on panel bridge release

PATCH In review Adam Miotk 2 participants 2 messages Jun 10, 2024

Subsystems (3)
lore
Share & tools
lore

Adam Miotk

author
#0 lore raw

PATCH 1/1 drm/bridge/panel: Fix runtime warning on panel bridge release

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).

---
 drivers/gpu/drm/bridge/panel.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/panel.c +5 -2
index 32506524d9a2..fe5fb08c9fc4 100644
@@ -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);
 }
 
 /**
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 4 lines · Adam Miotk

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.

Quoted 8 lines

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).

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