Skip to content

Commit 53ce9a3

Browse files
nixpanicMiklos Szeredi
authored andcommitted
fuse: readdirplus: fix dentry leak
In case d_lookup() returns a dentry with d_inode == NULL, the dentry is not returned with dput(). This results in triggering a BUG() in shrink_dcache_for_umount_subtree(): BUG: Dentry ...{i=0,n=...} still in use (1) [unmount of fuse fuse] [SzM: need to d_drop() as well] Reported-by: Justin Clift <jclift@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Tested-by: Brian Foster <bfoster@redhat.com> Tested-by: Niels de Vos <ndevos@redhat.com> CC: stable@vger.kernel.org
1 parent ad81f05 commit 53ce9a3

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎fs/fuse/dir.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,9 +1227,15 @@ static int fuse_direntplus_link(struct file *file,
12271227

12281228
name.hash = full_name_hash(name.name, name.len);
12291229
dentry = d_lookup(parent, &name);
1230-
if (dentry && dentry->d_inode) {
1230+
if (dentry) {
12311231
inode = dentry->d_inode;
1232-
if (get_node_id(inode) == o->nodeid) {
1232+
if (!inode) {
1233+
d_drop(dentry);
1234+
} else if (get_node_id(inode) != o->nodeid) {
1235+
err = d_invalidate(dentry);
1236+
if (err)
1237+
goto out;
1238+
} else {
12331239
struct fuse_inode *fi;
12341240
fi = get_fuse_inode(inode);
12351241
spin_lock(&fc->lock);
@@ -1242,9 +1248,6 @@ static int fuse_direntplus_link(struct file *file,
12421248
*/
12431249
goto found;
12441250
}
1245-
err = d_invalidate(dentry);
1246-
if (err)
1247-
goto out;
12481251
dput(dentry);
12491252
dentry = NULL;
12501253
}

0 commit comments

Comments
 (0)