All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: Detect API misuse of i_op->lookup
@ 2015-01-25 21:57 Richard Weinberger
  2015-01-25 22:16 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2015-01-25 21:57 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel, Richard Weinberger

Hunting down a refcount issue in an out-of-tree filesystem uncovered
that its lookup function directly returned the dentry which was passed to it.
Add a BUG_ON() to detect such misuse in future.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/namei.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/namei.c b/fs/namei.c
index bc35b02..f8ccae6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1370,6 +1370,7 @@ static struct dentry *lookup_real(struct inode *dir, struct dentry *dentry,
 
 	old = dir->i_op->lookup(dir, dentry, flags);
 	if (unlikely(old)) {
+		BUG_ON(old == dentry);
 		dput(dentry);
 		dentry = old;
 	}
-- 
2.2.2


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

end of thread, other threads:[~2015-01-25 22:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-25 21:57 [PATCH] fs: Detect API misuse of i_op->lookup Richard Weinberger
2015-01-25 22:16 ` Al Viro
2015-01-25 22:20   ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.