KVM: ARM/arm64: avoid returning negative error code as bool
authorWill Deacon <will.deacon@arm.com>
Tue, 26 Aug 2014 14:13:22 +0000 (15:13 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Thu, 2 Oct 2014 15:19:12 +0000 (17:19 +0200)
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>
(cherry picked from commit 18d457661fb9fa69352822ab98d39331c3d0e571)
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
arch/arm/kvm/coproc.c
arch/arm64/kvm/sys_regs.c

index 37a0fe1bb9bb3de3dbcb3139f4dc22b50f83063f..7928dbdf210239a71f4f35e8ef289e9c2e8f0375 100644 (file)
@@ -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);
index 5805e7c4a4ddf573603167c91244cf01d46813b1..4cc3b719208e0a8238930d44b409b2f7c2beb9f5 100644 (file)
@@ -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);