thermal: exynos: fix trips limit checking in get_th_reg()
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Thu, 26 Apr 2018 11:51:21 +0000 (13:51 +0200)
committerEduardo Valentin <edubezval@gmail.com>
Sun, 6 May 2018 23:19:05 +0000 (16:19 -0700)
of_thermal_get_ntrips() may return value bigger than supported
by a given SoC (i.e. on Exynos5422/5800) so fix the code to not
iterate the loop for i values >= data->ntrip.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/samsung/exynos_tmu.c

index 5a648794b667a294bb001677e3e8a0dba8bad921..58cd68e9bc1c14a2d4f3e7943a639b83b6db969d 100644 (file)
@@ -311,9 +311,9 @@ static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
        const struct thermal_trip * const trips =
                of_thermal_get_trip_points(tz);
        unsigned long temp;
-       int i;
+       int i, ntrips = min_t(int, of_thermal_get_ntrips(tz), data->ntrip);
 
-       for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
+       for (i = 0; i < ntrips; i++) {
                if (trips[i].type == THERMAL_TRIP_CRITICAL)
                        continue;