Module Name:    src
Committed By:   yamt
Date:           Thu Aug 18 14:13:02 UTC 2011

Modified Files:
        src/sys/uvm: uvm_anon.c

Log Message:
uvm_anon_freelst:
- clear an_link/an_ref when deferring anon disposal.  otherwise others can
  see bogus an_ref.
- fix the code to remove anon from the list.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/uvm/uvm_anon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/uvm_anon.c
diff -u src/sys/uvm/uvm_anon.c:1.60 src/sys/uvm/uvm_anon.c:1.61
--- src/sys/uvm/uvm_anon.c:1.60	Sun Aug 14 01:20:33 2011
+++ src/sys/uvm/uvm_anon.c	Thu Aug 18 14:13:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_anon.c,v 1.60 2011/08/14 01:20:33 rmind Exp $	*/
+/*	$NetBSD: uvm_anon.c,v 1.61 2011/08/18 14:13:02 yamt Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.60 2011/08/14 01:20:33 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.61 2011/08/18 14:13:02 yamt Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -214,22 +214,19 @@
 void
 uvm_anon_freelst(struct vm_amap *amap, struct vm_anon *anonlst)
 {
-	struct vm_anon *anon = anonlst, *prev = NULL, *next;
+	struct vm_anon *anon;
+	struct vm_anon **anonp = &anonlst;
 
 	KASSERT(mutex_owned(amap->am_lock));
-
-	while (anon) {
-		next = anon->an_link;
+	while ((anon = *anonp) != NULL) {
 		if (!uvm_anon_dispose(anon)) {
 			/* Do not free this anon. */
-			if (prev) {
-				prev->an_link = next;
-			} else {
-				anonlst = next;
-			}
+			*anonp = anon->an_link;
+			/* Note: clears an_ref as well. */
+			anon->an_link = NULL;
+		} else {
+			anonp = &anon->an_link;
 		}
-		prev = anon;
-		anon = next;
 	}
 	amap_unlock(amap);
 

Reply via email to