Skip to content

Commit 3f257bc

Browse files
committed
drm/tegra: gem: Do not return NULL in tegra_bo_mmap()
It's confusing for a function to return NULL and ERR_PTR()-encoded error codes on failure. Make sure we only ever return the latter since that's what callers already expect. Reported-by: Sui Jingfeng <[email protected]> Reviewed-by: Sui Jingfeng <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3868ff0 commit 3f257bc

File tree

1 file changed

+11
-2
lines changed
  • drivers/gpu/drm/tegra

1 file changed

+11
-2
lines changed

drivers/gpu/drm/tegra/gem.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,26 @@ static void *tegra_bo_mmap(struct host1x_bo *bo)
178178
{
179179
struct tegra_bo *obj = host1x_to_tegra_bo(bo);
180180
struct iosys_map map = { 0 };
181+
void *vaddr;
181182
int ret;
182183

183184
if (obj->vaddr)
184185
return obj->vaddr;
185186

186187
if (obj->gem.import_attach) {
187188
ret = dma_buf_vmap_unlocked(obj->gem.import_attach->dmabuf, &map);
188-
return ret ? NULL : map.vaddr;
189+
if (ret < 0)
190+
return ERR_PTR(ret);
191+
192+
return map.vaddr;
189193
}
190194

191-
return vmap(obj->pages, obj->num_pages, VM_MAP, pgprot_writecombine(PAGE_KERNEL));
195+
vaddr = vmap(obj->pages, obj->num_pages, VM_MAP,
196+
pgprot_writecombine(PAGE_KERNEL));
197+
if (!vaddr)
198+
return ERR_PTR(-ENOMEM);
199+
200+
return vaddr;
192201
}
193202

194203
static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)

0 commit comments

Comments
 (0)