drm/msm: correct attempted NULL pointer dereference in put_iova
authorBrian Masney <masneyb@onstation.org>
Mon, 3 Jun 2019 01:01:31 +0000 (21:01 -0400)
committerRob Clark <robdclark@chromium.org>
Tue, 18 Jun 2019 21:03:16 +0000 (14:03 -0700)
put_iova() would attempt to dereference a NULL pointer via the
address space pointer when no IOMMU is present. Correct this by adding
the appropriate check.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/msm_gem.c

index 35f55dd259944e3c2ea67e666fab8befcf27c5bb..d31d9f927887c732adf1908c215acd9452c52697 100644 (file)
@@ -352,8 +352,10 @@ put_iova(struct drm_gem_object *obj)
        WARN_ON(!mutex_is_locked(&msm_obj->lock));
 
        list_for_each_entry_safe(vma, tmp, &msm_obj->vmas, list) {
-               msm_gem_purge_vma(vma->aspace, vma);
-               msm_gem_close_vma(vma->aspace, vma);
+               if (vma->aspace) {
+                       msm_gem_purge_vma(vma->aspace, vma);
+                       msm_gem_close_vma(vma->aspace, vma);
+               }
                del_vma(vma);
        }
 }