mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
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:
@@ -217,7 +217,7 @@ struct sg_table *__nvmap_sg_table(struct nvmap_client *client,
|
|||||||
|
|
||||||
npages = PAGE_ALIGN(h->size) >> PAGE_SHIFT;
|
npages = PAGE_ALIGN(h->size) >> PAGE_SHIFT;
|
||||||
sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
|
sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
|
||||||
if (!sgt) {
|
if (sgt == NULL) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ static int nvmap_open(struct inode *inode, struct file *filp)
|
|||||||
|
|
||||||
BUG_ON(dev != nvmap_dev);
|
BUG_ON(dev != nvmap_dev);
|
||||||
priv = __nvmap_create_client(dev, "user");
|
priv = __nvmap_create_client(dev, "user");
|
||||||
if (!priv)
|
if (priv == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
trace_nvmap_open(priv, priv->name);
|
trace_nvmap_open(priv, priv->name);
|
||||||
|
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma)
|
|||||||
if (!h)
|
if (!h)
|
||||||
return -EINVAL;
|
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);
|
nvmap_handle_put(h);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ int __init nvmap_co_setup(struct reserved_mem *rmem)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
co = nvmap_get_carveout_pdata(rmem->name);
|
co = nvmap_get_carveout_pdata(rmem->name);
|
||||||
if (!co)
|
if (co == NULL)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
rmem->ops = &nvmap_co_ops;
|
rmem->ops = &nvmap_co_ops;
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ int nvmap_page_pool_alloc_lots(struct nvmap_page_pool *pool,
|
|||||||
while (ind < nr) {
|
while (ind < nr) {
|
||||||
struct page *page = NULL;
|
struct page *page = NULL;
|
||||||
|
|
||||||
if (!non_zero_cnt)
|
if (non_zero_cnt == 0U)
|
||||||
page = get_page_list_page(pool, use_numa, numa_id);
|
page = get_page_list_page(pool, use_numa, numa_id);
|
||||||
|
|
||||||
if (!page) {
|
if (!page) {
|
||||||
|
|||||||
Reference in New Issue
Block a user