]> 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)
committerLuis Henriques <luis.henriques@canonical.com>
Wed, 20 May 2015 12:25:43 +0000 (13:25 +0100)
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: Luis Henriques <luis.henriques@canonical.com>
arch/arm/kvm/coproc.c
arch/arm64/kvm/sys_regs.c

index c58a35116f6307781064761f919dcd2112e22c20..7c732908f1df4fa3da8e66f3b0fd195b7071e096 100644 (file)
@@ -742,7 +742,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 34f25a590bd7fdcbccc6953b52513019a1c57b6c..444e8edd71b2c24d8b6595880d8d8879d23186f7 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);