Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754596AbZJEGfC (ORCPT ); Mon, 5 Oct 2009 02:35:02 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754051AbZJEGfA (ORCPT ); Mon, 5 Oct 2009 02:35:00 -0400 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:56053 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753966AbZJEGfA (ORCPT ); Mon, 5 Oct 2009 02:35:00 -0400 X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Message-ID: <4AC99361.6060906@jp.fujitsu.com> Date: Mon, 05 Oct 2009 15:34:09 +0900 From: Hidetoshi Seto User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Huang Ying CC: Ingo Molnar , "H. Peter Anvin" , Andi Kleen , "linux-kernel@vger.kernel.org" Subject: [PATCH 02/10] x86, mce: mce_read can check args without mutex References: <1253269241.15717.525.camel@yhuang-dev.sh.intel.com> <4AC990E1.7030708@jp.fujitsu.com> In-Reply-To: <4AC990E1.7030708@jp.fujitsu.com> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1180 Lines: 40 Move it before mutex_lock(). Signed-off-by: Hidetoshi Seto --- arch/x86/kernel/cpu/mcheck/mce.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 28e1e14..2d0f9d8 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -1458,15 +1458,12 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, unsigned prev, next; int i, err; - mutex_lock(&mce_read_mutex); - next = rcu_dereference(mcelog.next); - /* Only supports full reads right now */ - if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) { - mutex_unlock(&mce_read_mutex); - + if (*off != 0 || usize < sizeof(struct mce) * MCE_LOG_LEN) return -EINVAL; - } + + mutex_lock(&mce_read_mutex); + next = rcu_dereference(mcelog.next); err = 0; prev = 0; -- 1.6.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/