drm/msm/dpu: Avoid calling _dpu_kms_mmu_destroy() on init failure [Linux 5.3]

This Linux kernel change "drm/msm/dpu: Avoid calling _dpu_kms_mmu_destroy() on init failure" is included in the Linux 5.3 release. This change is authored by Sean Paul <seanpaul [at] chromium.org> on Mon Jun 17 16:03:46 2019 -0400. The commit for this change in Linux stable tree is a93be1f (patch).

drm/msm/dpu: Avoid calling _dpu_kms_mmu_destroy() on init failure

Fix the error paths in _dpu_kms_mmu_init() to properly
clean up the iommu domain and not call _dpu_kms_mmu_destroy() when
things are only partially setup.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190617200405.131843-2-sean@poorly.run

There are 13 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 4518e74..435b846 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -745,25 +745,20 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
    aspace = msm_gem_address_space_create(dpu_kms->dev->dev,
            domain, "dpu1");
    if (IS_ERR(aspace)) {
-       ret = PTR_ERR(aspace);
-       goto fail;
+       iommu_domain_free(domain);
+       return PTR_ERR(aspace);
    }

-   dpu_kms->base.aspace = aspace;
-
    ret = aspace->mmu->funcs->attach(aspace->mmu, iommu_ports,
            ARRAY_SIZE(iommu_ports));
    if (ret) {
        DPU_ERROR("failed to attach iommu %d\n", ret);
        msm_gem_address_space_put(aspace);
-       goto fail;
+       return ret;
    }

+   dpu_kms->base.aspace = aspace;
    return 0;
-fail:
-   _dpu_kms_mmu_destroy(dpu_kms);
-
-   return ret;
 }

 static struct dss_clk *_dpu_kms_get_clk(struct dpu_kms *dpu_kms,

Leave a Reply

Your email address will not be published. Required fields are marked *