video: tegra: nvmap: Add Check for NULL & 0 Value

Fix for Rule: Misra-C 2012 Rule 10.1

-In nvmap_pp.c return type of non_zero_cnt is integer not boolean, hence
compare it with 0.

-In nvmap_dmabuf.c the result for & operation would be 0 or 1, hence
compare it with 0.

-In nvmap_core.c the return type of kzalloc is pointer, hence compare it
with NULL.

-In nvmap_dev.c priv is a pointer, hence compare it with NULL.

CID 1608945
CID 1617267
CID 1622229
CID 1625991
CID 1630899

JIRA TMM-5627

Change-Id: Ib40286f852cdade2e115384d18f615ae52134bdd
Signed-off-by: Surbhi Singh <surbhis@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3197795
Reviewed-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Ashish Mhetre <amhetre@nvidia.com>
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Tested-by: Sachin Nikam <snikam@nvidia.com>
This commit is contained in:
Surbhi Singh
2024-08-21 13:33:07 +00:00
committed by Jon Hunter
parent 4a1b0df1df
commit 9d96826773
5 changed files with 5 additions and 5 deletions

View File

@@ -369,7 +369,7 @@ int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma)
if (!h)
return -EINVAL;
if (!(h->heap_type & nvmap_dev->cpu_access_mask)) {
if ((h->heap_type & nvmap_dev->cpu_access_mask) == 0U) {
nvmap_handle_put(h);
return -EPERM;
}