]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/msm: fix use-after-free on probe deferral
authorJohan Hovold <johan+linaro@kernel.org>
Tue, 13 Sep 2022 08:53:11 +0000 (10:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Nov 2022 15:00:22 +0000 (00:00 +0900)
commit 6808abdb33bf90330e70a687d29f038507e06ebb upstream.

The bridge counter was never reset when tearing down the DRM device so
that stale pointers to deallocated structures would be accessed on the
next tear down (e.g. after a second late bind deferral).

Given enough bridges and a few probe deferrals this could currently also
lead to data beyond the bridge array being corrupted.

Fixes: d28ea556267c ("drm/msm: properly add and remove internal bridges")
Fixes: a3376e3ec81c ("drm/msm: convert to drm_bridge")
Cc: stable@vger.kernel.org # 3.12
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Reviewed-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/502665/
Link: https://lore.kernel.org/r/20220913085320.8577-2-johan+linaro@kernel.org
Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/msm/msm_drv.c

index 0759e2d99f59c478a70ba83d3f0ce8e1d59dc04c..869ba58f0254449717c4e8d21cdd6d433753c5ef 100644 (file)
@@ -241,6 +241,7 @@ static int msm_drm_uninit(struct device *dev)
 
        for (i = 0; i < priv->num_bridges; i++)
                drm_bridge_remove(priv->bridges[i]);
+       priv->num_bridges = 0;
 
        pm_runtime_get_sync(dev);
        msm_irq_uninstall(ddev);