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

@@ -217,7 +217,7 @@ struct sg_table *__nvmap_sg_table(struct nvmap_client *client,
npages = PAGE_ALIGN(h->size) >> PAGE_SHIFT;
sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
if (!sgt) {
if (sgt == NULL) {
err = -ENOMEM;
goto err;
}

View File

@@ -298,7 +298,7 @@ static int nvmap_open(struct inode *inode, struct file *filp)
BUG_ON(dev != nvmap_dev);
priv = __nvmap_create_client(dev, "user");
if (!priv)
if (priv == NULL)
return -ENOMEM;
trace_nvmap_open(priv, priv->name);

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;
}

View File

@@ -698,7 +698,7 @@ int __init nvmap_co_setup(struct reserved_mem *rmem)
int ret = 0;
co = nvmap_get_carveout_pdata(rmem->name);
if (!co)
if (co == NULL)
return ret;
rmem->ops = &nvmap_co_ops;

View File

@@ -312,7 +312,7 @@ int nvmap_page_pool_alloc_lots(struct nvmap_page_pool *pool,
while (ind < nr) {
struct page *page = NULL;
if (!non_zero_cnt)
if (non_zero_cnt == 0U)
page = get_page_list_page(pool, use_numa, numa_id);
if (!page) {