Skip to content

Commit

Permalink
KVM: ARM/arm64: avoid returning negative error code as bool
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Will Deacon authored and Christoffer Dall committed Aug 27, 2014
1 parent 4000be4 commit 18d4576
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/arm/kvm/coproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ static bool is_valid_cache(u32 val)
u32 level, ctype;

if (val >= CSSELR_MAX)
return -ENOENT;
return false;

/* Bottom bit is Instruction or Data bit. Next 3 bits are level. */
level = (val >> 1);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kvm/sys_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ static bool is_valid_cache(u32 val)
u32 level, ctype;

if (val >= CSSELR_MAX)
return -ENOENT;
return false;

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

0 comments on commit 18d4576

Please sign in to comment.