]> git.baikalelectronics.ru Git - kernel.git/commitdiff
microblaze: Prevent the overflow of the start
authorShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Sat, 11 Jan 2020 13:14:34 +0000 (18:44 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 4 Feb 2020 10:38:59 +0000 (11:38 +0100)
In case the start + cache size is more than the max int the
start overflows.
Prevent the same.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/microblaze/kernel/cpu/cache.c

index 0bde47e4fa694264256c1e8d2498436acc66320b..dcba53803fa5f9867eba2a0178c48ee5ed924c20 100644 (file)
@@ -92,7 +92,8 @@ static inline void __disable_dcache_nomsr(void)
 #define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size)   \
 do {                                                                   \
        int align = ~(cache_line_length - 1);                           \
-       end = min(start + cache_size, end);                             \
+       if (start <  UINT_MAX - cache_size)                             \
+               end = min(start + cache_size, end);                     \
        start &= align;                                                 \
 } while (0)