]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerJiri Slaby <jslaby@suse.cz>
Thu, 30 Apr 2015 09:15:08 +0000 (11:15 +0200)
commit 18d457661fb9fa69352822ab98d39331c3d0e571 upstream.

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>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
arch/arm/kvm/coproc.c
arch/arm64/kvm/sys_regs.c

index 24edbdea617eda83bc7980669d51c43bdf1f9712..4dc9256d48a381528eeaa380efbd5bfc7fbfabe6 100644 (file)
@@ -621,7 +621,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 5ee99e43890a9185d13082e6123fc88a16e852c0..7691b2563d27fbd24a076e38a97445fae0092fda 100644 (file)
@@ -836,7 +836,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);