[Differential] D8685: Fix a false positive in a buf_ring assert

rstone (Ryan Stone) phabric-noreply at FreeBSD.org
Wed Nov 30 23:41:40 UTC 2016


rstone updated this revision to Diff 22633.
rstone added a comment.


  Ensure we don't walk off the end of the ring

CHANGES SINCE LAST UPDATE
  https://reviews.freebsd.org/D8685?vs=22631&id=22633

REVISION DETAIL
  https://reviews.freebsd.org/D8685

AFFECTED FILES
  sys/sys/buf_ring.h

CHANGE DETAILS

diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h
--- a/sys/sys/buf_ring.h
+++ b/sys/sys/buf_ring.h
@@ -67,11 +67,13 @@
 	uint32_t prod_head, prod_next, cons_tail;
 #ifdef DEBUG_BUFRING
 	int i;
-	for (i = br->br_cons_head; i != br->br_prod_head;
-	     i = ((i + 1) & br->br_cons_mask))
-		if(br->br_ring[i] == buf)
-			panic("buf=%p already enqueue at %d prod=%d cons=%d",
-			    buf, i, br->br_prod_tail, br->br_cons_tail);
+	if (br->br_cons_head != br->br_prod_head) {
+		for (i = (br->br_cons_head + 1) & br->br_cons_mask; i != br->br_prod_head;
+		    i = ((i + 1) & br->br_cons_mask))
+			if(br->br_ring[i] == buf)
+				panic("buf=%p already enqueue at %d prod=%d cons=%d",
+				    buf, i, br->br_prod_tail, br->br_cons_tail);
+	}
 #endif	
 	critical_enter();
 	do {



EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: rstone
Cc: hselasky, freebsd-net-list, emaste
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8685.22633.patch
Type: text/x-patch
Size: 780 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-net/attachments/20161130/dde22dae/attachment.bin>


More information about the freebsd-net mailing list