mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: fix static analysis issues
coverity tool is not detecting the lenght validation done at caller. moved length checks to appropriate functions. used macro instead of hardcoded values. Jira NVGPU-4780 Change-Id: Ie6b420a6e625eed5374715fd7ca5c87d3ba3d015 Signed-off-by: sagar <skadamati@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2302335 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
@@ -443,7 +443,15 @@ static int nvgpu_vm_init_user_lp_vma(struct gk20a *g, struct vm_gk20a *vm,
|
||||
const char *name)
|
||||
{
|
||||
int err = 0;
|
||||
char alloc_name[32];
|
||||
char alloc_name[NVGPU_VM_NAME_LEN];
|
||||
size_t name_len;
|
||||
|
||||
name_len = strlen("gk20a_") + strlen(name) + strlen("_lp");
|
||||
if (name_len >= NVGPU_VM_NAME_LEN) {
|
||||
nvgpu_err(g, "Invalid MAX_NAME_SIZE %lu %u", name_len,
|
||||
NVGPU_VM_NAME_LEN);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* User VMA for large pages when a split address range is used.
|
||||
@@ -473,7 +481,15 @@ static int nvgpu_vm_init_kernel_vma(struct gk20a *g, struct vm_gk20a *vm,
|
||||
u64 kernel_vma_flags, const char *name)
|
||||
{
|
||||
int err = 0;
|
||||
char alloc_name[32];
|
||||
char alloc_name[NVGPU_VM_NAME_LEN];
|
||||
size_t name_len;
|
||||
|
||||
name_len = strlen("gk20a_") + strlen(name) + strlen("-sys");
|
||||
if (name_len >= NVGPU_VM_NAME_LEN) {
|
||||
nvgpu_err(g, "Invalid MAX_NAME_SIZE %lu %u", name_len,
|
||||
NVGPU_VM_NAME_LEN);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Kernel VMA.
|
||||
@@ -505,13 +521,6 @@ static int nvgpu_vm_init_vma_allocators(struct gk20a *g, struct vm_gk20a *vm,
|
||||
u64 kernel_vma_flags, const char *name)
|
||||
{
|
||||
int err = 0;
|
||||
size_t name_len;
|
||||
|
||||
name_len = strlen("gk20a_") + strlen(name);
|
||||
if (name_len >= 32U) {
|
||||
nvgpu_err(g, "Invalid MAX_NAME_SIZE %lu %u", name_len, 32U);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = nvgpu_vm_init_user_vma(g, vm,
|
||||
user_vma_start, user_vma_limit, name);
|
||||
|
||||
@@ -97,7 +97,7 @@ struct nvgpu_os_buffer;
|
||||
#include <nvgpu_rmos/include/vm.h>
|
||||
#endif
|
||||
|
||||
#define NVGPU_VM_NAME_LEN 20U
|
||||
#define NVGPU_VM_NAME_LEN 32U
|
||||
|
||||
/**
|
||||
* This structure describes the properties of batch mapping/unmapping.
|
||||
|
||||
Reference in New Issue
Block a user