]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm/msm: Fix IOMMU clean up path in case msm_iommu_new() fails
authorStephane Viau <sviau@codeaurora.org>
Tue, 15 Sep 2015 12:41:46 +0000 (08:41 -0400)
committerRob Clark <robdclark@gmail.com>
Thu, 22 Oct 2015 19:39:54 +0000 (15:39 -0400)
msm_iommu_new() can fail and this change makes sure that we
detect the failure and free the allocated domain before going
any further.

Signed-off-by: Stephane Viau <sviau@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/msm_gpu.c

index 047cb0433ccbe5156c5ebd2734b66586e75c7e27..7dbdced1fa3ca116fa3e8b7859b797fc43bf30e3 100644 (file)
@@ -586,6 +586,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
                if (IS_ERR(mmu)) {
                        ret = PTR_ERR(mmu);
                        dev_err(dev->dev, "failed to init iommu: %d\n", ret);
+                       iommu_domain_free(config->platform.iommu);
                        goto fail;
                }
 
index 8f70d9248ac55f7921acdaaea221577434bb3029..6b02ada6579a737d36f6ad7403ad53519ee7e0f7 100644 (file)
@@ -651,6 +651,14 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
        if (iommu) {
                dev_info(drm->dev, "%s: using IOMMU\n", name);
                gpu->mmu = msm_iommu_new(&pdev->dev, iommu);
+               if (IS_ERR(gpu->mmu)) {
+                       ret = PTR_ERR(gpu->mmu);
+                       dev_err(drm->dev, "failed to init iommu: %d\n", ret);
+                       gpu->mmu = NULL;
+                       iommu_domain_free(iommu);
+                       goto fail;
+               }
+
        } else {
                dev_info(drm->dev, "%s: no IOMMU, fallback to VRAM carveout!\n", name);
        }