drm/dp/mst: take lock around looking up the branch device on hpd irq
authorDave Airlie <airlied@redhat.com>
Mon, 22 Jun 2015 04:40:44 +0000 (14:40 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 23 Jun 2015 00:32:12 +0000 (10:32 +1000)
If we are doing an MST transaction and we've gotten HPD and we
lookup the device from the incoming msg, we should take the mgr
lock around it, so that mst_primary and mstb->ports are valid.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_dp_mst_topology.c

index 1c9670665281388267afb4c217f952420fa09982..f7213497ad6c40ca98aba1c6be03480a9a4e5ffd 100644 (file)
@@ -1163,6 +1163,8 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
        struct drm_dp_mst_port *port;
        int i;
        /* find the port by iterating down */
+
+       mutex_lock(&mgr->lock);
        mstb = mgr->mst_primary;
 
        for (i = 0; i < lct - 1; i++) {
@@ -1182,6 +1184,7 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
                }
        }
        kref_get(&mstb->kref);
+       mutex_unlock(&mgr->lock);
        return mstb;
 }