diff options
-rw-r--r-- | kernel/mutex.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/kernel/mutex.c b/kernel/mutex.c index 4f45d4b658ef..357c6d221efe 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c | |||
@@ -129,7 +129,6 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | |||
129 | { | 129 | { |
130 | struct task_struct *task = current; | 130 | struct task_struct *task = current; |
131 | struct mutex_waiter waiter; | 131 | struct mutex_waiter waiter; |
132 | unsigned int old_val; | ||
133 | unsigned long flags; | 132 | unsigned long flags; |
134 | 133 | ||
135 | spin_lock_mutex(&lock->wait_lock, flags); | 134 | spin_lock_mutex(&lock->wait_lock, flags); |
@@ -142,8 +141,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | |||
142 | list_add_tail(&waiter.list, &lock->wait_list); | 141 | list_add_tail(&waiter.list, &lock->wait_list); |
143 | waiter.task = task; | 142 | waiter.task = task; |
144 | 143 | ||
145 | old_val = atomic_xchg(&lock->count, -1); | 144 | if (atomic_xchg(&lock->count, -1) == 1) |
146 | if (old_val == 1) | ||
147 | goto done; | 145 | goto done; |
148 | 146 | ||
149 | lock_contended(&lock->dep_map, ip); | 147 | lock_contended(&lock->dep_map, ip); |
@@ -158,8 +156,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | |||
158 | * that when we release the lock, we properly wake up the | 156 | * that when we release the lock, we properly wake up the |
159 | * other waiters: | 157 | * other waiters: |
160 | */ | 158 | */ |
161 | old_val = atomic_xchg(&lock->count, -1); | 159 | if (atomic_xchg(&lock->count, -1) == 1) |
162 | if (old_val == 1) | ||
163 | break; | 160 | break; |
164 | 161 | ||
165 | /* | 162 | /* |