drm: fix some bridge api misunderstandings
Subsystems (4)
v2 cover drm: fix some bridge api misunderstandings
Hi!
The first patch was forgotten, so I improved the commit message based on the discussion from last time, and then added a patch with a requested documentation update.
See https://lkml.org/lkml/2018/5/2/81
Cheers,
Peter
Peter Rosin (2):
drm/sti: do not remove the drm_bridge that was never added
drm: bridge: document bridge attach/detach imbalance
drivers/gpu/drm/drm_bridge.c | 4 ++++ drivers/gpu/drm/sti/sti_hda.c | 1 - drivers/gpu/drm/sti/sti_hdmi.c | 1 - 3 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/2 drm/sti: do not remove the drm_bridge that was never added
Removing the drm_bridge_remove call should avoid a NULL dereference during list processing in drm_bridge_remove if the error path is ever taken.
The more natural approach would perhaps be to add a drm_bridge_add, but there are several other bridges that never call drm_bridge_add. Just removing the drm_bridge_remove is the easier fix.
--- drivers/gpu/drm/sti/sti_hda.c | 1 - drivers/gpu/drm/sti/sti_hdmi.c | 1 - 2 files changed, 2 deletions(-)
drivers/gpu/drm/sti/sti_hda.c +0 -1
@@ -721,7 +721,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data)return 0 ; err_sysfs: -drm_bridge_remove (bridge);return -EINVAL ; }
drivers/gpu/drm/sti/sti_hdmi.c +0 -1
@@ -1315,7 +1315,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)return 0 ; err_sysfs: -drm_bridge_remove (bridge); hdmi->drm_connector =NULL ;return -EINVAL ; }
Signature · 1 line
2.11.0
Re: [PATCH v2 1/2] drm/sti: do not remove the drm_bridge that was never added
2018-08-06 8:19 GMT+02:00 Peter Rosin <[email protected]>:
Quoted 11 lines
Removing the
drm_bridge_removecall should avoid a NULL dereference during list processing indrm_bridge_removeif the error path is ever taken.The more natural approach would perhaps be to add a
drm_bridge_add, but there are several other bridges that never calldrm_bridge_add. Just removing thedrm_bridge_removeis the easier fix.Fixes 84601dbdea36 ("drm: sti: rework init sequence")Acked-by Daniel Vetter <[email protected]>Signed-off-by Peter Rosin <[email protected]>
Pushed on drm-misc-next,
Thanks,
Benjamin
Quoted 32 lines
--- drivers/gpu/drm/sti/sti_hda.c | 1 - drivers/gpu/drm/sti/sti_hdmi.c | 1 - 2 files changed, 2 deletions(-)drivers/gpu/drm/sti/sti_hda.c +0
-1@@ -721,7 +721,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data)return 0 ; err_sysfs: -drm_bridge_remove (bridge);return -EINVAL ; }drivers/gpu/drm/sti/sti_hdmi.c +0
-2@@ -1315,7 +1315,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)return 0 ; err_sysfs: -drm_bridge_remove (bridge); hdmi->drm_connector =NULL ;return -EINVAL ; } --2.11.0
PATCH v2 2/2 drm: bridge: document bridge attach/detach imbalance
In reply to Peter RosinSince 4a878c03d562 ("drm: bridge: Detach bridge from encoder at encoder cleanup time"), it is generally no longer correct to detach bridges from encoders manually. Document that.
--- drivers/gpu/drm/drm_bridge.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_bridge.c +4 -0
@@ -104,6 +104,10 @@ EXPORT_SYMBOL(drm_bridge_remove);* If non-NULL the previous bridge must be already attached by a call to this * function. * +* Note that bridges attached to encoders are auto-detached during encoder +* cleanup in drm_encoder_cleanup(), so drm_bridge_attach() should generally +* *not* be balanced with a drm_bridge_detach() in driver code. +* * RETURNS: * Zero on success, error code on failure */
Signature · 1 line
2.11.0
Andrzej Hajda
AppliedRe: [PATCH v2 2/2] drm: bridge: document bridge attach/detach imbalance
Quoted 14 lines · Peter Rosin
Since
4a878c03d562("drm: bridge: Detach bridge from encoder at encoder cleanup time"), it is generally no longer correct to detach bridges from encoders manually. Document that.Signed-off-by Peter Rosin <[email protected]>--- drivers/gpu/drm/drm_bridge.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/drm_bridge.c +0
-0
drivers/gpu/drm/drm_bridge.c EXPORT_SYMBOL(drm_bridge_remove); · line 113
Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +4
-0@@ -104,6 +104,10 @@ EXPORT_SYMBOL(drm_bridge_remove);* If non-NULL the previous bridge must be already attached by a call to this * function. * +* Note that bridges attached to encoders are auto-detached during encoder +* cleanup in drm_encoder_cleanup(), so drm_bridge_attach() should generally +* *not* be balanced with a drm_bridge_detach() in driver code. +* * RETURNS: * Zero on success, error code on failure */
Pushed to drm-misc-next.
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel