public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: menage@google.com (Paul Menage)
To: viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Add a refcount check in dput()
Date: Mon, 10 Sep 2007 15:13:19 -0700 (PDT)	[thread overview]
Message-ID: <20070910221319.302473D66CF@localhost> (raw)

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();

             reply	other threads:[~2007-09-10 22:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-10 22:13 Paul Menage [this message]
2007-09-15  8:39 ` [PATCH] Add a refcount check in dput() Andrew Morton
2007-09-17 18:21   ` Paul Menage
2007-09-17 20:48     ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070910221319.302473D66CF@localhost \
    --to=menage@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox