Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 May 2009 01:45:24 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192868 - head/sys/dev/xen/netfront
Message-ID:  <200905270145.n4R1jOne080108@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed May 27 01:45:23 2009
New Revision: 192868
URL: http://svn.freebsd.org/changeset/base/192868

Log:
  Add in some INVARIANT checks in the TX mbuf descriptor "freelist" management code.
  
  Slot 0 must always remain "free" and be a pointer to the first free entry in the
  mbuf descriptor list. It is thus an error to have code allocate or push slot 0
  back into the list.

Modified:
  head/sys/dev/xen/netfront/netfront.c

Modified: head/sys/dev/xen/netfront/netfront.c
==============================================================================
--- head/sys/dev/xen/netfront/netfront.c	Wed May 27 01:30:23 2009	(r192867)
+++ head/sys/dev/xen/netfront/netfront.c	Wed May 27 01:45:23 2009	(r192868)
@@ -310,6 +310,7 @@ struct netfront_rx_info {
 static inline void
 add_id_to_freelist(struct mbuf **list, unsigned short id)
 {
+	KASSERT(id != 0, ("add_id_to_freelist: the head item (0) must always be free."));
 	list[id] = list[0];
 	list[0]  = (void *)(u_long)id;
 }
@@ -318,6 +319,7 @@ static inline unsigned short
 get_id_from_freelist(struct mbuf **list)
 {
 	u_int id = (u_int)(u_long)list[0];
+	KASSERT(id != 0, ("get_id_from_freelist: the head item (0) must always remain free."));
 	list[0] = list[id];
 	return (id);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905270145.n4R1jOne080108>