[PATCH] fs: Detect API misuse of i_op->lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux