Skip to content

Commit 18d4576

Browse files
wildea01chazy
authored andcommitted
KVM: ARM/arm64: avoid returning negative error code as bool
is_valid_cache returns true if the specified cache is valid. Unfortunately, if the parameter passed it out of range, we return -ENOENT, which ends up as true leading to potential hilarity. This patch returns false on the failure path instead. Cc: Christoffer Dall <christoffer.dall@linaro.org> Cc: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
1 parent 4000be4 commit 18d4576

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/arm/kvm/coproc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static bool is_valid_cache(u32 val)
791791
u32 level, ctype;
792792

793793
if (val >= CSSELR_MAX)
794-
return -ENOENT;
794+
return false;
795795

796796
/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */
797797
level = (val >> 1);

‎arch/arm64/kvm/sys_regs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ static bool is_valid_cache(u32 val)
12181218
u32 level, ctype;
12191219

12201220
if (val >= CSSELR_MAX)
1221-
return -ENOENT;
1221+
return false;
12221222

12231223
/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */
12241224
level = (val >> 1);

0 commit comments

Comments
 (0)