From: Al Viro Date: Thu, 9 May 2024 05:07:01 +0000 (-0400) Subject: convert fuse_ctl X-Git-Tag: v6.19-rc1~111^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a8993a15a79f03cd1a43ddc071d0e49a1247cd5;p=thirdparty%2Fkernel%2Flinux.git convert fuse_ctl objects are created in fuse_ctl_add_dentry() by d_alloc_name()+d_add(), removed by simple_remove_by_name(). What we return is a borrowed reference - it is valid until the call of fuse_ctl_remove_conn() and we depend upon the exclusion (on fuse_mutex) for safety. Return value is used only within the caller (fuse_ctl_add_conn()). Replace d_add() with d_make_persistent() + dput(). dput() is paired with d_alloc_name() and return value is the result of d_make_persistent(). Acked-by: Miklos Szeredi Signed-off-by: Al Viro --- diff --git a/fs/fuse/control.c b/fs/fuse/control.c index 3dca752127ff8..140bd5730d998 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -236,8 +236,14 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, inc_nlink(inode); } inode->i_private = fc; - d_add(dentry, inode); - + d_make_persistent(dentry, inode); + dput(dentry); + + /* + * We are returning a borrowed reference here - it's only good while + * fuse_mutex is held. Actually it's d_make_persistent() return + * value... + */ return dentry; } @@ -346,7 +352,7 @@ static void fuse_ctl_kill_sb(struct super_block *sb) fuse_control_sb = NULL; mutex_unlock(&fuse_mutex); - kill_litter_super(sb); + kill_anon_super(sb); } static struct file_system_type fuse_ctl_fs_type = {