lkml.org 
[lkml]   [2009]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 02/10] x86, mce: mce_read can check args without mutex
Move it before mutex_lock().

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
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



\
 
 \ /
  Last update: 2009-10-05 08:39    [from the cache]
©2003-2011 Jasper Spaans