Module Name:    src
Committed By:   riastradh
Date:           Sun Sep  8 15:33:35 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: kref.h

Log Message:
Fix sense of atomic_cas loop condition and use kassertmsg for krefs.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
    src/sys/external/bsd/drm2/include/linux/kref.h

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

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/kref.h
diff -u src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.3
--- src/sys/external/bsd/drm2/include/linux/kref.h:1.1.2.2	Wed Jul 24 01:51:36 2013
+++ src/sys/external/bsd/drm2/include/linux/kref.h	Sun Sep  8 15:33:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: kref.h,v 1.1.2.2 2013/07/24 01:51:36 riastradh Exp $	*/
+/*	$NetBSD: kref.h,v 1.1.2.3 2013/09/08 15:33:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@ kref_get(struct kref *kref)
 	const unsigned int count __unused =
 	    atomic_inc_uint_nv(&kref->kr_count);
 
-	KASSERT(count > 1);
+	KASSERTMSG((count > 1), "getting released kref");
 }
 
 static inline int
@@ -64,9 +64,10 @@ kref_sub(struct kref *kref, unsigned int
 
 	do {
 		old = kref->kr_count;
-		KASSERT(count <= old);
+		KASSERTMSG((count <= old), "overreleasing kref: %u - %u",
+		    old, count);
 		new = (old - count);
-	} while (atomic_cas_uint(&kref->kr_count, old, new) == old);
+	} while (atomic_cas_uint(&kref->kr_count, old, new) != old);
 
 	if (new == 0) {
 		(*release)(kref);

Reply via email to