From patchwork Tue Jun 2 14:48:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49384 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D398520BD1 for ; Tue, 2 Jun 2015 14:49:55 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf42703598lbc.2 for ; Tue, 02 Jun 2015 07:49:54 -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=Iq76l7iGdHhNRFdWhgq5AHEUAEuQwXK9ZnSMfdUk68miFBMzx6o1Ws43nDM7LkJAiO 9rsZZbhfZVn6EEHsNLLmadjVuv1M0XYQinFt/dK36J4qoOpNFStX8Q/PFau920ZWNpFB m3BRPjNRJpy5vZpFvDW/9IEqbnf63J6HwhC8orWxj3GzMM6vF6g9TmZbdZCQVTVDOyMo wsrhBmS+HmIi92j9Tvot9zmOMuD7+BKFMtlKa7mrO6BqYEcb+9hwBXUX0OnJBokkGO0u POmQEgeW0zPBuqcjKYXw/N0aU/H+e2u7uCkZnnJjzyYmL4sEmJC29CWF20M/lxBU1ypX 6ZRA== X-Gm-Message-State: ALoCoQmJ7r8EZWgKfTkFwqDAXA/nRgd1gKbNtUjOsrIZdui3sA64CIuwcHTnhwPT4uSr98VUPYIs X-Received: by 10.112.142.170 with SMTP id rx10mr25902008lbb.12.1433256594793; Tue, 02 Jun 2015 07:49:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.133 with SMTP id kq5ls742942lac.102.gmail; Tue, 02 Jun 2015 07:49:54 -0700 (PDT) X-Received: by 10.152.30.34 with SMTP id p2mr21555134lah.89.1433256594640; Tue, 02 Jun 2015 07:49:54 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id j5si15260259laf.127.2015.06.02.07.49.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:49:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laew7 with SMTP id w7so35350863lae.1 for ; Tue, 02 Jun 2015 07:49:54 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr26651220lbc.19.1433256594525; Tue, 02 Jun 2015 07:49:54 -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.108.230 with SMTP id hn6csp3128649lbb; Tue, 2 Jun 2015 07:49:52 -0700 (PDT) X-Received: by 10.66.66.140 with SMTP id f12mr51928575pat.120.1433256587424; Tue, 02 Jun 2015 07:49:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hv8si26697315pdb.173.2015.06.02.07.49.46; Tue, 02 Jun 2015 07:49:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759356AbbFBOtq (ORCPT + 2 others); Tue, 2 Jun 2015 10:49:46 -0400 Received: from mail-ob0-f175.google.com ([209.85.214.175]:35748 "EHLO mail-ob0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759059AbbFBOtp (ORCPT ); Tue, 2 Jun 2015 10:49:45 -0400 Received: by obcnx10 with SMTP id nx10so123899406obc.2 for ; Tue, 02 Jun 2015 07:49:44 -0700 (PDT) X-Received: by 10.202.98.193 with SMTP id w184mr21606578oib.96.1433256584913; Tue, 02 Jun 2015 07:49:44 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id x3sm9566555obm.8.2015.06.02.07.49.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:49:44 -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 09/32] KVM: ARM/arm64: avoid returning negative error code as bool Date: Tue, 2 Jun 2015 22:48:04 +0800 Message-Id: <1433256507-7856-10-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> References: <1433256507-7856-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.52 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);