From patchwork Mon May 4 01:52:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47961 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9313A2121F for ; Mon, 4 May 2015 01:55:24 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf40431879wgi.3 for ; Sun, 03 May 2015 18:55:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=pfpJlAEASisjIBirguajvcnNHA1q7Iz2HbAl5yRkAIs=; b=jkTPgSArE0udFdoTnEWUr848JbQunNXpnC4UZmW3+1xK9o/iNasQJSG+z9hKTn8UZ0 edl6FXcV52e/Kq+sLJN2IFSPU8mCYxfulrsJhG6cIxuO25T9P6pqwRWcwK7vbt3rGYEg tt5KOYW7bwRMk7/o6cOKnLxFDIkFU+qZv3f33lUn/ALv7Q+byezQnQN9F1OeFQQqYHTr XWkWyOHG3Moj7kiYnGk7lcqTbRw6NNZOlZC/sYETRQ7fzDA8enbgXFFgteLOE+60mcDI aRFnplTicPaEf2GDMWpSawOBJ26GRuzIsJu44eAHSRRrEHfLYFPwh3qgkwgpKocbV7gV Y+HA== X-Gm-Message-State: ALoCoQlPeMzh+9QQYr5CKMOTEgTTKdTAoOKW7zLV22atFwRaTC3iYO/EsC8K2b69biTe19fXnxU7 X-Received: by 10.180.97.9 with SMTP id dw9mr6916865wib.2.1430704523943; Sun, 03 May 2015 18:55:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.163 with SMTP id an3ls712813lac.90.gmail; Sun, 03 May 2015 18:55:23 -0700 (PDT) X-Received: by 10.112.202.103 with SMTP id kh7mr9990463lbc.118.1430704523781; Sun, 03 May 2015 18:55:23 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id ys9si9089780lab.63.2015.05.03.18.55.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:55:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagv1 with SMTP id v1so94964215lag.3 for ; Sun, 03 May 2015 18:55:23 -0700 (PDT) X-Received: by 10.153.8.167 with SMTP id dl7mr17663251lad.86.1430704523704; Sun, 03 May 2015 18:55:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1412919lbt; Sun, 3 May 2015 18:55:22 -0700 (PDT) X-Received: by 10.68.252.106 with SMTP id zr10mr38400761pbc.79.1430704521793; Sun, 03 May 2015 18:55:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.55.21; Sun, 03 May 2015 18:55:21 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbbEDBzU (ORCPT + 2 others); Sun, 3 May 2015 21:55:20 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:32994 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751923AbbEDBzT (ORCPT ); Sun, 3 May 2015 21:55:19 -0400 Received: by pdbnk13 with SMTP id nk13so150013011pdb.0 for ; Sun, 03 May 2015 18:55:19 -0700 (PDT) X-Received: by 10.70.100.36 with SMTP id ev4mr37905657pdb.73.1430704519177; Sun, 03 May 2015 18:55:19 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id fn6sm11064977pab.31.2015.05.03.18.55.17 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:55:17 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Will Deacon , Marc Zyngier Subject: [PATCH for 3.14.y stable 24/47] KVM: ARM/arm64: avoid returning negative error code as bool Date: Mon, 4 May 2015 09:52:19 +0800 Message-Id: <1430704362-6292-25-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Will Deacon 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 Cc: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Christoffer Dall Signed-off-by: Shannon Zhao --- arch/arm/kvm/coproc.c | 2 +- arch/arm64/kvm/sys_regs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index c58a351..7c73290 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -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); diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 5ee99e4..7691b25 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -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);