Revert "drm/msm: Fix failure paths in msm_drm_init()"
authorJohan Hovold <johan+linaro@kernel.org>
Mon, 6 Mar 2023 10:07:14 +0000 (11:07 +0100)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 6 Apr 2023 17:29:39 +0000 (20:29 +0300)
This reverts commit 8636500300a01740d92b345c680b036b94555b1b.

A recent commit tried to address a drm device leak in the early
msm_drm_uninit() error paths but ended up making things worse.

Specifically, it moved the drm device reference put in msm_drm_uninit()
to msm_drm_init() which means that the drm would now be leaked on normal
unbind.

For reasons that were never spelled out, it also added kms NULL pointer
checks to a couple of helper functions that had nothing to do with the
paths modified by the patch.

Instead of trying to salvage this incrementally, let's revert the bad
commit so that clean and backportable fixes can be added in its place.

Fixes: 8636500300a0 ("drm/msm: Fix failure paths in msm_drm_init()")
Cc: Akhil P Oommen <quic_akhilpo@quicinc.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/525092/
Link: https://lore.kernel.org/r/20230306100722.28485-3-johan+linaro@kernel.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c
drivers/gpu/drm/msm/msm_drv.c

index b73031cd48e4891fca671170f80e3b1df329e53d..e75b97127c0d18b2cbb9ee34c00d981eb73e6e3f 100644 (file)
@@ -129,9 +129,6 @@ void msm_disp_snapshot_destroy(struct drm_device *drm_dev)
        }
 
        priv = drm_dev->dev_private;
-       if (!priv->kms)
-               return;
-
        kms = priv->kms;
 
        if (kms->dump_worker)
index df88d948fc70bafffedd1c10db77f18c984665ed..3286ba78f89ad284d4fc7dff87e7cb0d52680a4f 100644 (file)
@@ -151,9 +151,6 @@ static void msm_irq_uninstall(struct drm_device *dev)
        struct msm_drm_private *priv = dev->dev_private;
        struct msm_kms *kms = priv->kms;
 
-       if (!priv->kms)
-               return;
-
        kms->funcs->irq_uninstall(kms);
        if (kms->irq_requested)
                free_irq(kms->irq, dev);
@@ -271,6 +268,8 @@ static int msm_drm_uninit(struct device *dev)
        component_unbind_all(dev, ddev);
 
        ddev->dev_private = NULL;
+       drm_dev_put(ddev);
+
        destroy_workqueue(priv->wq);
 
        return 0;
@@ -443,12 +442,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
 
        ret = msm_init_vram(ddev);
        if (ret)
-               goto err_drm_dev_put;
+               return ret;
 
        /* Bind all our sub-components: */
        ret = component_bind_all(dev, ddev);
        if (ret)
-               goto err_drm_dev_put;
+               return ret;
 
        dma_set_max_seg_size(dev, UINT_MAX);
 
@@ -543,8 +542,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
 
 err_msm_uninit:
        msm_drm_uninit(dev);
-err_drm_dev_put:
-       drm_dev_put(ddev);
        return ret;
 }