Skip to content

Commit 3ac173e

Browse files
cyndisgregkh
authored andcommitted
gpu: host1x: Fix iommu_map_sgtable() return value check
[ Upstream commit 18f7476 ] 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. pin_job() also was incorrectly assigning to 'int', which could cause overflows into negative values. Update pin_job() to correctly check for errors from iommu_map_sgtable. Fixes: ad8f36e ("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-1-fb484c07d2a1@nvidia.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3d211fb commit 3ac173e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/gpu/host1x/job.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
235235
}
236236

237237
if (host->domain) {
238+
ssize_t map_err;
239+
238240
for_each_sgtable_sg(map->sgt, sg, j)
239241
gather_size += sg->length;
240242

@@ -248,11 +250,11 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
248250
goto put;
249251
}
250252

251-
err = iommu_map_sgtable(host->domain, iova_dma_addr(&host->iova, alloc),
252-
map->sgt, IOMMU_READ);
253-
if (err == 0) {
253+
map_err = iommu_map_sgtable(host->domain, iova_dma_addr(&host->iova, alloc),
254+
map->sgt, IOMMU_READ);
255+
if (map_err < 0) {
254256
__free_iova(&host->iova, alloc);
255-
err = -EINVAL;
257+
err = map_err;
256258
goto put;
257259
}
258260

0 commit comments

Comments
 (0)