[PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
Keith Busch
kbusch at kernel.org
Fri Dec 3 07:01:53 PST 2021
On Fri, Dec 03, 2021 at 07:47:15PM +0800, Hou Tao wrote:
> Zeroing ana_log_size as well after free ana_log_buf, otherwise
> when nvme_read_ana_log() or kmalloc() fails, ana_log_size
> will be valid but ana_log_buf is NULL, and the next call of
> nvme_mpath_init_identify() will fail definitely.
The next init could still succeed if the next new size is greater than
the old size, but yes, this looks like a good fix.
Reviewed-by: Keith Busch <kbusch at kernel.org>
> Signed-off-by: Hou Tao <houtao1 at huawei.com>
> ---
> drivers/nvme/host/multipath.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index afa33845420d..17e61a1baa69 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -869,7 +869,7 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
> }
> if (ana_log_size > ctrl->ana_log_size) {
> nvme_mpath_stop(ctrl);
> - kfree(ctrl->ana_log_buf);
> + nvme_mpath_uninit(ctrl);
> ctrl->ana_log_buf = kmalloc(ana_log_size, GFP_KERNEL);
> if (!ctrl->ana_log_buf)
> return -ENOMEM;
> @@ -895,4 +895,5 @@ void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
> {
> kfree(ctrl->ana_log_buf);
> ctrl->ana_log_buf = NULL;
> + ctrl->ana_log_size = 0;
> }
> --
More information about the Linux-nvme
mailing list