Re: [PATCH] ceph: fix invalid point dereference for error case in mdsc destroy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 14, 2018 at 1:47 PM, Chengguang Xu <cgxu519@xxxxxxx> wrote:
> 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@xxxxxxx>
> ---
>  fs/ceph/mds_client.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index e932c06..97dcc04 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -3598,7 +3598,6 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
>         if (!mdsc)
>                 return -ENOMEM;
>         mdsc->fsc = fsc;
> -       fsc->mdsc = mdsc;
>         mutex_init(&mdsc->mutex);
>         mdsc->mdsmap = kzalloc(sizeof(*mdsc->mdsmap), GFP_NOFS);
>         if (!mdsc->mdsmap) {
> @@ -3606,6 +3605,7 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
>                 return -ENOMEM;
>         }
>
> +       fsc->mdsc = mdsc;
>         init_completion(&mdsc->safe_umount_waiters);
>         init_waitqueue_head(&mdsc->session_close_wq);
>         INIT_LIST_HEAD(&mdsc->waiting_for_map);
> @@ -3891,6 +3891,9 @@ void ceph_mdsc_destroy(struct ceph_fs_client *fsc)
>         struct ceph_mds_client *mdsc = fsc->mdsc;
>         dout("mdsc_destroy %p\n", mdsc);
>
> +       if (!mdsc)
> +               return;
> +
>         /* flush out any connection work with references to us */
>         ceph_msgr_flush();
>
> --
> 1.8.3.1
>

Applied, thanks

Yan, Zheng

> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux