diff --git a/arch/risc-v/src/mpfs/mpfs_mpu.c b/arch/risc-v/src/mpfs/mpfs_mpu.c index 2643c79c0ac7a..2adaf3d911c58 100644 --- a/arch/risc-v/src/mpfs/mpfs_mpu.c +++ b/arch/risc-v/src/mpfs/mpfs_mpu.c @@ -159,9 +159,11 @@ int mpfs_mpu_set(uintptr_t reg, uintptr_t perm, uintptr_t base, return -EACCES; } - /* Base must be word aligned, minimum size is 4K */ + /* Base must be word aligned, + * minimum size is 4K and it has to be power-of-two + */ - if ((base & 0x07) != 0 || size < 0x1000) + if ((base & 0x07) != 0 || size < 0x1000 || (size & (size - 1)) != 0) { return -EINVAL; }