From 57a65081dd16ec96671a79efd4e7bc275ea1fb80 Mon Sep 17 00:00:00 2001 From: Manish Bhardwaj Date: Mon, 17 Feb 2025 17:29:10 +0000 Subject: [PATCH] nvidia-oot: cert & misra fixes in cpuidle-tegra-auto.c drv using this patch fixing below cert & misra errors:- - cert_arr30_c_violation: "__per_cpu_offset[cpu]" evaluates to an address that could be at negative offset of an array. JIRA ESLC-8401 Change-Id: I99670f9823cda5abaa41368b80821a5727414017 Signed-off-by: Manish Bhardwaj Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3304761 Reviewed-by: Sumeet Gupta Reviewed-by: Suresh Venkatachalam GVS: buildbot_gerritrpt --- drivers/cpuidle/cpuidle-tegra-auto.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle-tegra-auto.c b/drivers/cpuidle/cpuidle-tegra-auto.c index 0ede7ff4..49b008ac 100644 --- a/drivers/cpuidle/cpuidle-tegra-auto.c +++ b/drivers/cpuidle/cpuidle-tegra-auto.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include @@ -157,6 +157,11 @@ static int __init tegra_auto_idle_init_cpu(int cpu) int ret = 0; struct cpuidle_driver *drv; + if (cpu < 0 || cpu >= nr_cpu_ids) { + pr_err("Invalid CPU index: %d\n", cpu); + return -EINVAL; + } + drv = kmemdup(&tegra_auto_idle_driver, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM;