gpu: nvgpu: sanitize TEGRA_RAW attribute

TEGRA_RAW mappings are only supposed to be used in special
circumstances by user space software, and the request cannot
be treated as a hint and be silently ignored if the feature
is not supported.

This patch updates the logic to return error if the feature is
not supported.

Jira NVGPU-6640
Bug 3489827

Change-Id: Ia2ce71df0202ab0c8676b815cf887cc7300aa07f
Signed-off-by: Martin Radev <mradev@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2676168
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Martin Radev
2022-03-01 11:22:50 +02:00
committed by mobile promotions
parent cb70e86ac1
commit 8cba20ff42

View File

@@ -397,6 +397,13 @@ int nvgpu_vm_map_buffer(struct vm_gk20a *vm,
return -EINVAL;
}
if (((flags & NVGPU_AS_MAP_BUFFER_FLAGS_TEGRA_RAW) != 0U) &&
!nvgpu_is_enabled(g, NVGPU_SUPPORT_TEGRA_RAW)) {
nvgpu_err(g, "TEGRA_RAW requested when not supported.");
dma_buf_put(dmabuf);
return -EINVAL;
}
err = nvgpu_vm_map_linux(vm, dmabuf, *map_addr, map_access,
nvgpu_vm_translate_linux_flags(g, flags),
page_size,