diff --git a/drivers/media/platform/tegra/cdi/cdi_mgr.c b/drivers/media/platform/tegra/cdi/cdi_mgr.c index 5f42c403..e4b25fbf 100644 --- a/drivers/media/platform/tegra/cdi/cdi_mgr.c +++ b/drivers/media/platform/tegra/cdi/cdi_mgr.c @@ -660,7 +660,8 @@ static int cdi_mgr_get_pwr_info(struct cdi_mgr_priv *cdi_mgr, 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, "%s: invalid power gpio provided\n", __func__); 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); + 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]); err = 0; diff --git a/include/trace/events/tegra_rtcpu.h b/include/trace/events/tegra_rtcpu.h index b1b4cb5d..279575ff 100644 --- a/include/trace/events/tegra_rtcpu.h +++ b/include/trace/events/tegra_rtcpu.h @@ -1,6 +1,6 @@ /* 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 @@ -10,6 +10,7 @@ #define _TRACE_TEGRA_RTCPU_H #include +#include #include /* @@ -119,7 +120,7 @@ TRACE_EVENT(rtcpu_string, __entry->tstamp = tstamp; __entry->id = id; __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\"", __entry->tstamp, __entry->id, @@ -282,7 +283,8 @@ TRACE_EVENT(rtcpu_vinotify_event, __entry->tstamp, __entry->channel_id, __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] : __print_hex(&__entry->tag_tag, 1), __entry->tag_channel, __entry->tag_frame,