From 29095ac135021adafcb621bfc7003db5aef7bf57 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 2 Apr 2019 18:04:14 -0700 Subject: [PATCH] arc: fix off-by-one in _is_in_region() Similar issue to what was fixed earlier in the MPUv3 code. start + size should be <= r_addr_end. Fixes a problem where the last byte of an MPU region is incorrectly reported as out-of-bounds. Fixes: #15131 Signed-off-by: Andrew Boie --- arch/arc/core/mpu/arc_mpu_v2_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/core/mpu/arc_mpu_v2_internal.h b/arch/arc/core/mpu/arc_mpu_v2_internal.h index 82ea6273692..837b5599a64 100644 --- a/arch/arc/core/mpu/arc_mpu_v2_internal.h +++ b/arch/arc/core/mpu/arc_mpu_v2_internal.h @@ -118,7 +118,7 @@ static inline bool _is_in_region(u32_t r_index, u32_t start, u32_t size) r_size_lshift = (r_size_lshift & 0x3) | ((r_size_lshift >> 7) & 0x1C); r_addr_end = r_addr_start + (1 << (r_size_lshift + 1)); - if (start >= r_addr_start && (start + size) < r_addr_end) { + if (start >= r_addr_start && (start + size) <= r_addr_end) { return 1; }