Skip to content

Commit 2960935

Browse files
Telecaster2147Rbb666
authored andcommitted
fix(libcpu): correct arm mpu region validation precedence
1 parent dedff58 commit 2960935

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

libcpu/arm/cortex-m33/mpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ rt_bool_t rt_hw_mpu_region_valid(rt_mem_region_t *region)
108108
LOG_E("Region size is too small");
109109
return RT_FALSE;
110110
}
111-
if (region->size & (~(MPU_MIN_REGION_SIZE - 1U)) != region->size)
111+
if ((region->size & (~(MPU_MIN_REGION_SIZE - 1U))) != region->size)
112112
{
113113
LOG_E("Region size is not a multiple of 32 bytes");
114114
return RT_FALSE;
115115
}
116-
if ((rt_uint32_t)region->start & (MPU_MIN_REGION_SIZE - 1U) != 0U)
116+
if (((rt_uint32_t)region->start & (MPU_MIN_REGION_SIZE - 1U)) != 0U)
117117
{
118118
LOG_E("Region is not aligned by 32 bytes");
119119
return RT_FALSE;

libcpu/arm/cortex-m7/mpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ rt_bool_t rt_hw_mpu_region_valid(rt_mem_region_t *region)
7171
LOG_E("Region size is too small");
7272
return RT_FALSE;
7373
}
74-
if (region->size & (region->size - 1U) != 0U)
74+
if ((region->size & (region->size - 1U)) != 0U)
7575
{
7676
LOG_E("Region size is not power of 2");
7777
return RT_FALSE;
7878
}
79-
if ((rt_uint32_t)region->start & (region->size - 1U) != 0U)
79+
if (((rt_uint32_t)region->start & (region->size - 1U)) != 0U)
8080
{
8181
LOG_E("Region is not naturally aligned");
8282
return RT_FALSE;

0 commit comments

Comments
 (0)