Commit 087d268b authored by Chengguang Xu's avatar Chengguang Xu Committed by Greg Kroah-Hartman

ceph: fix dentry leak when failing to init debugfs

[ Upstream commit 18106734 ]

When failing from ceph_fs_debugfs_init() in ceph_real_mount(),
there is lack of dput of root_dentry and it causes slab errors,
so change the calling order of ceph_fs_debugfs_init() and
open_root_dentry() and do some cleanups to avoid this issue.
Signed-off-by: default avatarChengguang Xu <cgxu519@icloud.com>
Reviewed-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8a25a9d6
...@@ -816,7 +816,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) ...@@ -816,7 +816,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
int err; int err;
unsigned long started = jiffies; /* note the start time */ unsigned long started = jiffies; /* note the start time */
struct dentry *root; struct dentry *root;
int first = 0; /* first vfsmount for this super_block */
dout("mount start %p\n", fsc); dout("mount start %p\n", fsc);
mutex_lock(&fsc->client->mount_mutex); mutex_lock(&fsc->client->mount_mutex);
...@@ -834,17 +833,17 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) ...@@ -834,17 +833,17 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
path = fsc->mount_options->server_path + 1; path = fsc->mount_options->server_path + 1;
dout("mount opening path %s\n", path); dout("mount opening path %s\n", path);
} }
err = ceph_fs_debugfs_init(fsc);
if (err < 0)
goto out;
root = open_root_dentry(fsc, path, started); root = open_root_dentry(fsc, path, started);
if (IS_ERR(root)) { if (IS_ERR(root)) {
err = PTR_ERR(root); err = PTR_ERR(root);
goto out; goto out;
} }
fsc->sb->s_root = dget(root); fsc->sb->s_root = dget(root);
first = 1;
err = ceph_fs_debugfs_init(fsc);
if (err < 0)
goto fail;
} else { } else {
root = dget(fsc->sb->s_root); root = dget(fsc->sb->s_root);
} }
...@@ -854,11 +853,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) ...@@ -854,11 +853,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)
mutex_unlock(&fsc->client->mount_mutex); mutex_unlock(&fsc->client->mount_mutex);
return root; return root;
fail:
if (first) {
dput(fsc->sb->s_root);
fsc->sb->s_root = NULL;
}
out: out:
mutex_unlock(&fsc->client->mount_mutex); mutex_unlock(&fsc->client->mount_mutex);
return ERR_PTR(err); return ERR_PTR(err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment