Skip to content

Commit

Permalink
drm/tegra: gem: Do not return NULL in tegra_bo_mmap()
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
thierryreding committed Oct 11, 2023
1 parent 3868ff0 commit 3f257bc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/gpu/drm/tegra/gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,26 @@ static void *tegra_bo_mmap(struct host1x_bo *bo)
{
struct tegra_bo *obj = host1x_to_tegra_bo(bo);
struct iosys_map map = { 0 };
void *vaddr;
int ret;

if (obj->vaddr)
return obj->vaddr;

if (obj->gem.import_attach) {
ret = dma_buf_vmap_unlocked(obj->gem.import_attach->dmabuf, &map);
return ret ? NULL : map.vaddr;
if (ret < 0)
return ERR_PTR(ret);

return map.vaddr;
}

return vmap(obj->pages, obj->num_pages, VM_MAP, pgprot_writecombine(PAGE_KERNEL));
vaddr = vmap(obj->pages, obj->num_pages, VM_MAP,
pgprot_writecombine(PAGE_KERNEL));
if (!vaddr)
return ERR_PTR(-ENOMEM);

return vaddr;
}

static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
Expand Down

0 comments on commit 3f257bc

Please sign in to comment.