Skip to contentSkip to conversation

x86/mm: Fix operator associativity bug in mm-locks.h

PATCH Applied Andres Lagar-Cavilla 2 participants 2 messages Jan 12, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Fix operator associativity bug in mm-locks.h

 xen/arch/x86/mm/mm-locks.h |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

In an order-enforcing wrapper for an "external" recursive lock, we aim to increment/decrement a recurse count and only update the lock ordering on zero counts.

Unfortunately we incrementing/decrementing the pointer to the recurse count, rather than the count itself.

xen/arch/x86/mm/mm-locks.h +2 -2
diff -r 91f9a26a8d94 -r e7028b298fe3 xen/arch/x86/mm/mm-locks.h
@@ -81,7 +81,7 @@ static inline void _mm_enforce_order_loc
 {
     if ( recurse_count )
     {
-        if ( *recurse_count++ == 0 )
+        if ( (*recurse_count)++ == 0 )
         {
             *unlock_level = __get_lock_level();
         }
@@ -125,7 +125,7 @@ static inline void mm_enforce_order_unlo
     if ( recurse_count )
     {
         BUG_ON(*recurse_count == 0);
-        if ( *recurse_count-- == 1 )
+        if ( (*recurse_count)-- == 1 )
         {
             __set_lock_level(unlock_level);
         }
Applied
#1 lore raw
Quoted 6 lines · Andres Lagar-Cavilla

In an order-enforcing wrapper for an "external" recursive lock, we aim to increment/decrement a recurse count and only update the lock ordering on zero counts.

Unfortunately we incrementing/decrementing the pointer to the recurse count, rather than the count itself.

Applied, thanks.

Tim