diff options
author | Chengguang Xu <cgxu519@icloud.com> | 2018-02-09 20:40:59 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-30 07:52:04 +0200 |
commit | 6c88c93898ca3cebf27c5ea96585560bb81959a2 (patch) | |
tree | d1a9820261d8ca2e6f00b0190c46f7da94a68598 /fs | |
parent | e080e814deb129f1e3b928af58f61177bd8e8dab (diff) | |
download | linux-stable-6c88c93898ca3cebf27c5ea96585560bb81959a2.tar.gz linux-stable-6c88c93898ca3cebf27c5ea96585560bb81959a2.tar.bz2 linux-stable-6c88c93898ca3cebf27c5ea96585560bb81959a2.zip |
ceph: fix dentry leak when failing to init debugfs
[ Upstream commit 18106734b512664a8541026519ce4b862498b6c3 ]
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: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/super.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 7d892bbc4f54..9c907e3aad26 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -837,7 +837,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) int err; unsigned long started = jiffies; /* note the start time */ struct dentry *root; - int first = 0; /* first vfsmount for this super_block */ dout("mount start %p\n", fsc); mutex_lock(&fsc->client->mount_mutex); @@ -862,17 +861,17 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) path = fsc->mount_options->server_path + 1; 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); if (IS_ERR(root)) { err = PTR_ERR(root); goto out; } fsc->sb->s_root = dget(root); - first = 1; - - err = ceph_fs_debugfs_init(fsc); - if (err < 0) - goto fail; } else { root = dget(fsc->sb->s_root); } @@ -882,11 +881,6 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) mutex_unlock(&fsc->client->mount_mutex); return root; -fail: - if (first) { - dput(fsc->sb->s_root); - fsc->sb->s_root = NULL; - } out: mutex_unlock(&fsc->client->mount_mutex); return ERR_PTR(err); |