]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/tegra: Fix iommu_map_sgtable() return value check
authorMikko Perttunen <mperttunen@nvidia.com>
Tue, 21 Apr 2026 04:02:37 +0000 (13:02 +0900)
committerThierry Reding <treding@nvidia.com>
Thu, 28 May 2026 15:19:30 +0000 (17:19 +0200)
Commit "iommu: return full error code from iommu_map_sg[_atomic]()"
changed iommu_map_sgtable() to return an ssize_t and negative values
in error cases, rather than a size_t and a zero.

Update tegra_bo_iommu_map() to correctly check for errors from
iommu_map_sgtable.

Fixes: ad8f36e4b6b1 ("iommu: return full error code from iommu_map_sg[_atomic]()")
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patch.msgid.link/20260421-iommu_map_sgtable-return-v1-2-fb484c07d2a1@nvidia.com
drivers/gpu/drm/tegra/gem.c

index 2377e2b76397a320998da3fbea399f1b351e43f3..436394e0481252f65f22e7dd84c9b23639faae5a 100644 (file)
@@ -234,6 +234,7 @@ static const struct host1x_bo_ops tegra_bo_ops = {
 static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
 {
        int prot = IOMMU_READ | IOMMU_WRITE;
+       ssize_t size;
        int err;
 
        if (bo->mm)
@@ -255,13 +256,15 @@ static int tegra_bo_iommu_map(struct tegra_drm *tegra, struct tegra_bo *bo)
 
        bo->iova = bo->mm->start;
 
-       bo->size = iommu_map_sgtable(tegra->domain, bo->iova, bo->sgt, prot);
-       if (!bo->size) {
+       size = iommu_map_sgtable(tegra->domain, bo->iova, bo->sgt, prot);
+       if (size < 0) {
                dev_err(tegra->drm->dev, "failed to map buffer\n");
-               err = -ENOMEM;
+               err = size;
                goto remove;
        }
 
+       bo->size = size;
+
        mutex_unlock(&tegra->mm_lock);
 
        return 0;