public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add a refcount check in dput()
@ 2007-09-10 22:13 Paul Menage
  2007-09-15  8:39 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Menage @ 2007-09-10 22:13 UTC (permalink / raw)
  To: viro; +Cc: linux-kernel

Add a BUG_ON() to check for passing an unreferenced dentry to dput().

This is analogous to the similar check in dget(), and will make
reference-counting bugs in filesystems more immediately obvious. (I
just spent a while debugging an oops that turned out to be due to
broken fs reference counting.)

Signed-off-by: Paul Menage <menage@google.com>

---
 fs/dcache.c |    1 +
 1 file changed, 1 insertion(+)

Index: container-2.6.23-rc3-mm1/fs/dcache.c
===================================================================
--- container-2.6.23-rc3-mm1.orig/fs/dcache.c
+++ container-2.6.23-rc3-mm1/fs/dcache.c
@@ -176,6 +176,7 @@ void dput(struct dentry *dentry)
 	if (!dentry)
 		return;
 
+	BUG_ON(!atomic_read(&dentry->d_count));
 repeat:
 	if (atomic_read(&dentry->d_count) == 1)
 		might_sleep();

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-17 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10 22:13 [PATCH] Add a refcount check in dput() Paul Menage
2007-09-15  8:39 ` Andrew Morton
2007-09-17 18:21   ` Paul Menage
2007-09-17 20:48     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox