misc: tegra-profiler: fix coverity issue
Igor Nabirushkin [Tue, 28 Apr 2015 06:04:15 +0000 (10:04 +0400)]
Fix Coverity issue of out-of-bounds.
Coverity id: 29855

Bug 1416640

Change-Id: I112daaad55c1a2de9fdb411a0591e4ed7bf50e6e
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/730896
(cherry picked from commit 09c1b2add13aa7c6f4410c874ddad936913f5d19)
Reviewed-on: http://git-master/r/748092
GVS: Gerrit_Virtual_Submit
Reviewed-by: Andrey Trachenko <atrachenko@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>

drivers/misc/tegra-profiler/power_clk.c

index 7af0753..b7b1983 100644 (file)
@@ -210,7 +210,7 @@ read_source(struct power_clk_source *s, int cpu)
        switch (s->type) {
        case QUADD_POWER_CLK_CPU:
                /* update cpu frequency */
-               if (cpu < 0 || cpu >= POWER_CLK_MAX_VALUES) {
+               if (cpu < 0 || cpu >= max_t(int, s->nr, nr_cpu_ids)) {
                        pr_err_once("error: cpu id: %d\n", cpu);
                        break;
                }