aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2018-03-14 01:47:33 -0400
committerIlya Dryomov <idryomov@gmail.com>2018-04-02 04:12:49 -0400
commit50c55aeca27f09ceda0cd58b72b0addeecef74eb (patch)
tree58598250a7a96fca1ecc48d90bdead6a5a5e5fae
parent98cfda81040f4a6925a98567d036a918e855d4ec (diff)
ceph: fix invalid point dereference for error case in mdsc destroy
1. set fsc->mdsc after successfully allocate all necessary memory in mdsc init. 2. if fsc->mdsc is NULL, just skip destroy operation in mdsc destroy. Signed-off-by: Chengguang Xu <cgxu519@gmx.com> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r--fs/ceph/mds_client.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 3a555b604441..b50044374947 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -3575,7 +3575,6 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
3575 if (!mdsc) 3575 if (!mdsc)
3576 return -ENOMEM; 3576 return -ENOMEM;
3577 mdsc->fsc = fsc; 3577 mdsc->fsc = fsc;
3578 fsc->mdsc = mdsc;
3579 mutex_init(&mdsc->mutex); 3578 mutex_init(&mdsc->mutex);
3580 mdsc->mdsmap = kzalloc(sizeof(*mdsc->mdsmap), GFP_NOFS); 3579 mdsc->mdsmap = kzalloc(sizeof(*mdsc->mdsmap), GFP_NOFS);
3581 if (!mdsc->mdsmap) { 3580 if (!mdsc->mdsmap) {
@@ -3583,6 +3582,7 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
3583 return -ENOMEM; 3582 return -ENOMEM;
3584 } 3583 }
3585 3584
3585 fsc->mdsc = mdsc;
3586 init_completion(&mdsc->safe_umount_waiters); 3586 init_completion(&mdsc->safe_umount_waiters);
3587 init_waitqueue_head(&mdsc->session_close_wq); 3587 init_waitqueue_head(&mdsc->session_close_wq);
3588 INIT_LIST_HEAD(&mdsc->waiting_for_map); 3588 INIT_LIST_HEAD(&mdsc->waiting_for_map);
@@ -3861,6 +3861,9 @@ void ceph_mdsc_destroy(struct ceph_fs_client *fsc)
3861 struct ceph_mds_client *mdsc = fsc->mdsc; 3861 struct ceph_mds_client *mdsc = fsc->mdsc;
3862 dout("mdsc_destroy %p\n", mdsc); 3862 dout("mdsc_destroy %p\n", mdsc);
3863 3863
3864 if (!mdsc)
3865 return;
3866
3864 /* flush out any connection work with references to us */ 3867 /* flush out any connection work with references to us */
3865 ceph_msgr_flush(); 3868 ceph_msgr_flush();
3866 3869