diff mbox

[v2,2/4] libibverbs: Undo changes in memory range tree when madvise() fails

Message ID 4B666D68.8010103@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Alex Vainman Feb. 1, 2010, 5:58 a.m. UTC
None
diff mbox

Patch

diff --git a/src/memory.c b/src/memory.c
index 51839e2..6a3305f 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -521,10 +521,8 @@  static int ibv_madvise_range(void *base, size_t size, int advice)
 			}
 		}
 
-		node->refcnt += inc;
-
-		if ((inc == -1 && node->refcnt == 0) ||
-		    (inc ==  1 && node->refcnt == 1)) {
+		if ((inc == -1 && node->refcnt == 1) ||
+		    (inc ==  1 && node->refcnt == 0)) {
 			/*
 			 * If this is the first time through the loop,
 			 * and we merged this node with the previous
@@ -547,6 +545,7 @@  static int ibv_madvise_range(void *base, size_t size, int advice)
 				goto out;
 		}
 
+		node->refcnt += inc;
 		node = __mm_next(node);
 	}