* [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
@ 2021-12-03 11:47 Hou Tao
2021-12-03 15:01 ` Keith Busch
2021-12-06 7:53 ` Christoph Hellwig
0 siblings, 2 replies; 5+ messages in thread
From: Hou Tao @ 2021-12-03 11:47 UTC (permalink / raw)
To: linux-nvme
Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg, Jens Axboe,
houtao1, jiangtao62
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.
Signed-off-by: Hou Tao <houtao1@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;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
2021-12-03 11:47 [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf Hou Tao
@ 2021-12-03 15:01 ` Keith Busch
2021-12-06 7:53 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Keith Busch @ 2021-12-03 15:01 UTC (permalink / raw)
To: Hou Tao
Cc: linux-nvme, Christoph Hellwig, Sagi Grimberg, Jens Axboe, jiangtao62
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@kernel.org>
> Signed-off-by: Hou Tao <houtao1@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;
> }
> --
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
2021-12-03 11:47 [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf Hou Tao
2021-12-03 15:01 ` Keith Busch
@ 2021-12-06 7:53 ` Christoph Hellwig
2021-12-06 9:43 ` Hou Tao
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-12-06 7:53 UTC (permalink / raw)
To: Hou Tao
Cc: linux-nvme, Keith Busch, Christoph Hellwig, Sagi Grimberg,
Jens Axboe, jiangtao62
> if (ana_log_size > ctrl->ana_log_size) {
> nvme_mpath_stop(ctrl);
> - kfree(ctrl->ana_log_buf);
> + nvme_mpath_uninit(ctrl);
This hunk looks unrelated.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
2021-12-06 7:53 ` Christoph Hellwig
@ 2021-12-06 9:43 ` Hou Tao
2021-12-07 17:18 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Hou Tao @ 2021-12-06 9:43 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-nvme, Keith Busch, Sagi Grimberg, Jens Axboe, jiangtao62
Hi,
On 12/6/2021 3:53 PM, Christoph Hellwig wrote:
>> if (ana_log_size > ctrl->ana_log_size) {
>> nvme_mpath_stop(ctrl);
>> - kfree(ctrl->ana_log_buf);
>> + nvme_mpath_uninit(ctrl);
> This hunk looks unrelated.
It will be related if the value of ana_log_size is reduced again, so you mean
the reduction is impossible ?
> .
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
2021-12-06 9:43 ` Hou Tao
@ 2021-12-07 17:18 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-12-07 17:18 UTC (permalink / raw)
To: Hou Tao
Cc: Christoph Hellwig, linux-nvme, Keith Busch, Sagi Grimberg,
Jens Axboe, jiangtao62
On Mon, Dec 06, 2021 at 05:43:10PM +0800, Hou Tao wrote:
> Hi,
>
> On 12/6/2021 3:53 PM, Christoph Hellwig wrote:
> >> if (ana_log_size > ctrl->ana_log_size) {
> >> nvme_mpath_stop(ctrl);
> >> - kfree(ctrl->ana_log_buf);
> >> + nvme_mpath_uninit(ctrl);
> > This hunk looks unrelated.
> It will be related if the value of ana_log_size is reduced again, so you mean
> the reduction is impossible ?
Ok, I see the intent now and will apply it with an updated changelog
to make that more clear.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-12-07 17:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 11:47 [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf Hou Tao
2021-12-03 15:01 ` Keith Busch
2021-12-06 7:53 ` Christoph Hellwig
2021-12-06 9:43 ` Hou Tao
2021-12-07 17:18 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.