kernel: nvidia-oot: Fix KMD coverity defects

Fix coverity defects
ARR38-C
STR07-C
INT30-C
INT08-C
ARR30-C

Jira CAMERASW-30853

Change-Id: I2e98db911238dca46f142f108f6563321e25b588
Signed-off-by: yangxu <yangxu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3281801
Reviewed-by: Sudhir Vyas <svyas@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Xiaoming Xiang <xxiang@nvidia.com>
Reviewed-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-by: Praveen AC <pac@nvidia.com>
This commit is contained in:
yangxu
2025-01-10 07:37:18 +00:00
committed by Jon Hunter
parent 4f3230c142
commit a972eca4b6
2 changed files with 15 additions and 4 deletions

View File

@@ -660,7 +660,8 @@ static int cdi_mgr_get_pwr_info(struct cdi_mgr_priv *cdi_mgr,
goto pwr_info_end; goto pwr_info_end;
} }
if (pinfo.pwr_gpio >= pd->num_pwr_gpios || pinfo.pwr_gpio < 0) { if (pinfo.pwr_gpio >= pd->num_pwr_gpios || pinfo.pwr_gpio < 0
|| pinfo.pwr_gpio >= MAX_CDI_GPIOS) {
dev_err(cdi_mgr->pdev, dev_err(cdi_mgr->pdev,
"%s: invalid power gpio provided\n", __func__); "%s: invalid power gpio provided\n", __func__);
pinfo.pwr_status = -1; pinfo.pwr_status = -1;
@@ -670,6 +671,14 @@ static int cdi_mgr_get_pwr_info(struct cdi_mgr_priv *cdi_mgr,
pinfo.pwr_gpio = array_index_nospec(pinfo.pwr_gpio, pd->num_pwr_gpios); pinfo.pwr_gpio = array_index_nospec(pinfo.pwr_gpio, pd->num_pwr_gpios);
if (pinfo.pwr_gpio < 0 || pinfo.pwr_gpio >= ARRAY_SIZE(pd->pwr_gpios)) {
dev_err(cdi_mgr->pdev,
"%s: set power status failed due to invalid power gpio value\n", __func__);
pinfo.pwr_status = -1;
err = -EINVAL;
goto pwr_info_end;
}
pinfo.pwr_status = gpio_get_value(pd->pwr_gpios[pinfo.pwr_gpio]); pinfo.pwr_status = gpio_get_value(pd->pwr_gpios[pinfo.pwr_gpio]);
err = 0; err = 0;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
/* /*
* SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/ */
#undef TRACE_SYSTEM #undef TRACE_SYSTEM
@@ -10,6 +10,7 @@
#define _TRACE_TEGRA_RTCPU_H #define _TRACE_TEGRA_RTCPU_H
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
#include <linux/string.h>
#include <soc/tegra/camrtc-trace.h> #include <soc/tegra/camrtc-trace.h>
/* /*
@@ -119,7 +120,7 @@ TRACE_EVENT(rtcpu_string,
__entry->tstamp = tstamp; __entry->tstamp = tstamp;
__entry->id = id; __entry->id = id;
__entry->len = len; __entry->len = len;
strncpy(__entry->data, data, sizeof(__entry->data)); strscpy(__entry->data, data, sizeof(__entry->data));
), ),
TP_printk("tstamp:%llu id:0x%08x str:\"%.*s\"", TP_printk("tstamp:%llu id:0x%08x str:\"%.*s\"",
__entry->tstamp, __entry->id, __entry->tstamp, __entry->id,
@@ -282,7 +283,8 @@ TRACE_EVENT(rtcpu_vinotify_event,
__entry->tstamp, __entry->tstamp,
__entry->channel_id, __entry->channel_id,
__entry->unit, __entry->unit,
((__entry->tag_tag >> 1) < g_trace_vinotify_tag_str_count) ? (((__entry->tag_tag >> 1) < g_trace_vinotify_tag_str_count) &&
((__entry->tag_tag >> 1) >= 0)) ?
g_trace_vinotify_tag_strs[__entry->tag_tag >> 1] : g_trace_vinotify_tag_strs[__entry->tag_tag >> 1] :
__print_hex(&__entry->tag_tag, 1), __print_hex(&__entry->tag_tag, 1),
__entry->tag_channel, __entry->tag_frame, __entry->tag_channel, __entry->tag_frame,