drm_encoder_cleanup() modifies the encoder chain by removing bridges via
drm_bridge_detach(). Protect this whole operation by taking the mutex, so
any users iterating over the chain will not access it during the change.

Signed-off-by: Luca Ceresoli <[email protected]>
---
 drivers/gpu/drm/drm_encoder.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 
3261f142baea30c516499d23dbf8d0acf5952cd6..3a04bedf9b759acd6826864b7f2cc9b861a8f170
 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -195,9 +195,11 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
         * the indices on the drm_encoder after us in the encoder_list.
         */
 
+       mutex_lock(&encoder->bridge_chain_mutex);
        list_for_each_entry_safe(bridge, next, &encoder->bridge_chain,
                                 chain_node)
                drm_bridge_detach(bridge);
+       mutex_unlock(&encoder->bridge_chain_mutex);
 
        drm_mode_object_unregister(dev, &encoder->base);
        kfree(encoder->name);

-- 
2.51.0

Reply via email to