Rather than silenty mapping nothing, treat this as an error.  It should
never happen, but if it does we want to flag the VM as unusable.

Signed-off-by: Rob Clark <[email protected]>
---
 drivers/gpu/drm/msm/msm_iommu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index c2950d32c507..255972323f9a 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -186,6 +186,10 @@ __do_map(unsigned long pgsize_bitmap, u64 iova, struct 
sg_table *sgt, size_t off
                        size -= mapped;
                        len  -= mapped;
 
+                       /* If nothing was mapped, consider it an ENOMEM. */
+                       if (!ret && !mapped)
+                               ret = -ENOMEM;
+
                        if (ret) {
                                __do_unmap(pgsize_bitmap, iova, addr - iova, 
arg, ops);
                                return -EINVAL;
-- 
2.56.0

Reply via email to