nvscic2c-pcie: Fix Top25 CWE CERT-C violations

Fix total 20 violations of rule CERT-C EXP34-C

JIRA NVIPC-3120

Change-Id: I1e8940269a2859a0483215cf44170dd669f637ea
Signed-off-by: chandra <cyeddu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3260920
Reviewed-by: Janardhan Reddy AnnapuReddy <jreddya@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
This commit is contained in:
chandra
2024-12-03 11:38:06 +00:00
committed by Jon Hunter
parent d5573ecc31
commit e946c2cbcc
3 changed files with 46 additions and 11 deletions

View File

@@ -1,5 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES.
* All rights reserved.
*/
#define pr_fmt(fmt) "nvscic2c-pcie: comm-channel: " fmt
@@ -375,7 +378,11 @@ allocate_fence(struct syncpt_t *syncpt)
int ret = 0;
struct dma_fence *fence = NULL;
fence = host1x_fence_create(syncpt->sp, ++syncpt->threshold, false);
if (syncpt->threshold == U32_MAX)
syncpt->threshold = 0;
else
++syncpt->threshold;
fence = host1x_fence_create(syncpt->sp, syncpt->threshold, false);
if (IS_ERR_OR_NULL(fence)) {
ret = PTR_ERR(fence);
pr_err("host1x_fence_create failed with: %d\n", ret);

View File

@@ -589,7 +589,11 @@ allocate_fence(struct syncpt_t *syncpt)
int ret = 0;
struct dma_fence *fence = NULL;
fence = host1x_fence_create(syncpt->sp, ++syncpt->threshold, false);
if (syncpt->threshold == U32_MAX)
syncpt->threshold = 0;
else
++syncpt->threshold;
fence = host1x_fence_create(syncpt->sp, syncpt->threshold, false);
if (IS_ERR(fence)) {
ret = PTR_ERR(fence);
pr_err("host1x_fence_create failed with: %d\n", ret);

View File

@@ -1030,7 +1030,10 @@ prepare_edma_desc(enum drv_mode_t drv_mode, struct copy_req_params *params,
fput(filep);
desc[iter].sz = flush_range->size;
iter++;
if (iter == U32_MAX)
iter = 0;
else
iter++;
}
*num_desc += iter;
return ret;
@@ -1127,10 +1130,16 @@ cache_copy_request_handles(struct copy_req_params *params,
stream_obj = filep->private_data;
kref_get(&stream_obj->refcount);
cr->handles[cr->num_handles] = stream_obj;
cr->num_handles++;
if (cr->num_handles == U64_MAX)
cr->num_handles = 0;
else
cr->num_handles++;
/* collect all local post fences separately for nvhost incr.*/
cr->local_post_fences[cr->num_local_post_fences] = stream_obj;
cr->num_local_post_fences++;
if (cr->num_local_post_fences == U64_MAX)
cr->num_local_post_fences = 0;
else
cr->num_local_post_fences++;
fput(filep);
}
for (i = 0; i < params->num_remote_post_fences; i++) {
@@ -1139,10 +1148,16 @@ cache_copy_request_handles(struct copy_req_params *params,
stream_obj = filep->private_data;
kref_get(&stream_obj->refcount);
cr->handles[cr->num_handles] = stream_obj;
cr->num_handles++;
if (cr->num_handles == U64_MAX)
cr->num_handles = 0;
else
cr->num_handles++;
cr->remote_post_fence_values[i] = params->remote_post_fence_values[i];
cr->remote_post_fences[cr->num_remote_post_fences] = stream_obj;
cr->num_remote_post_fences++;
if (cr->num_remote_post_fences == U64_MAX)
cr->num_remote_post_fences = 0;
else
cr->num_remote_post_fences++;
fput(filep);
}
for (i = 0; i < params->num_flush_ranges; i++) {
@@ -1151,7 +1166,10 @@ cache_copy_request_handles(struct copy_req_params *params,
stream_obj = filep->private_data;
kref_get(&stream_obj->refcount);
cr->handles[cr->num_handles] = stream_obj;
cr->num_handles++;
if (cr->num_handles == U64_MAX)
cr->num_handles = 0;
else
cr->num_handles++;
fput(filep);
handle = params->flush_ranges[i].dst_handle;
@@ -1159,10 +1177,16 @@ cache_copy_request_handles(struct copy_req_params *params,
stream_obj = filep->private_data;
kref_get(&stream_obj->refcount);
cr->handles[cr->num_handles] = stream_obj;
cr->num_handles++;
if (cr->num_handles == U64_MAX)
cr->num_handles = 0;
else
cr->num_handles++;
cr->remote_buf_objs[cr->num_remote_buf_objs] = stream_obj;
cr->num_remote_buf_objs++;
if (cr->num_remote_buf_objs == U64_MAX)
cr->num_remote_buf_objs = 0;
else
cr->num_remote_buf_objs++;
fput(filep);
}