From: Maurizio Lombardi <mlombard@redhat.com>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org, hch@lst.de, chaitanya.kulkarni@wdc.com
Subject: Re: [PATCH V2 3/3] nvmet-tcp: fix memory leak when performing a controller reset
Date: Tue, 16 Nov 2021 10:22:48 +0100 [thread overview]
Message-ID: <20211116092248.GG21836@raketa> (raw)
In-Reply-To: <6f864cab-8460-3956-5784-2c3669069028@grimberg.me>
On Tue, Nov 16, 2021 at 11:07:29AM +0200, Sagi Grimberg wrote:
>
> > If a reset controller is executed while the initiator
> > is performing some I/O the driver may leak the memory allocated
> > for the commands' iovec.
> >
> > Make sure that nvmet_tcp_uninit_data_in_cmds() releases
> > all the memory.
> >
> > Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> > ---
> > drivers/nvme/target/tcp.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
> > index 028b47ff0f0f..5a238fa067cd 100644
> > --- a/drivers/nvme/target/tcp.c
> > +++ b/drivers/nvme/target/tcp.c
> > @@ -1427,7 +1427,10 @@ static void nvmet_tcp_uninit_data_in_cmds(struct nvmet_tcp_queue *queue)
> > for (i = 0; i < queue->nr_cmds; i++, cmd++) {
> > if (nvmet_tcp_need_data_in(cmd))
> > - nvmet_tcp_finish_cmd(cmd);
> > + nvmet_req_uninit(&cmd->req);
> > +
> > + nvmet_tcp_unmap_pdu_iovec(cmd);
> > + nvmet_tcp_free_iovec(cmd);
>
> I understand how unmap_pdu_iovec is re-entrance safe, but sgl_free
> called from free_iovec is not. What prevents it from being called
> for commands that have already freed their sgls?
The commands that have already freed their sgls
will have the pointers set to NULL,
calling sgl_free() against a NULL pointer is safe (it does nothing, like kfree())
but if you prefer I will add a check.
Maurizio
next prev parent reply other threads:[~2021-11-16 9:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 16:31 [PATCH V2 0/3] Fix a race condition when performing a controller reset Maurizio Lombardi
2021-11-15 16:31 ` [PATCH V2 1/3] nvmet-tcp: add an helper to free the iovec Maurizio Lombardi
2021-11-16 9:00 ` Sagi Grimberg
2021-11-16 9:05 ` Maurizio Lombardi
2021-11-15 16:31 ` [PATCH V2 2/3] nvmet-tcp: fix a race condition between release_queue and io_work Maurizio Lombardi
2021-11-16 8:57 ` Sagi Grimberg
2021-11-15 16:31 ` [PATCH V2 3/3] nvmet-tcp: fix memory leak when performing a controller reset Maurizio Lombardi
2021-11-16 9:07 ` Sagi Grimberg
2021-11-16 9:22 ` Maurizio Lombardi [this message]
2021-11-16 10:11 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211116092248.GG21836@raketa \
--to=mlombard@redhat.com \
--cc=chaitanya.kulkarni@wdc.com \
--cc=hch@lst.de \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.