From: Klaus Jensen <its@irrelevant.dk>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Keith Busch <kbusch@kernel.org>,
qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>
Subject: Re: [PATCH 2/2] hw/nvme: fix memory leak in nvme_dsm
Date: Wed, 12 Apr 2023 12:02:40 +0200 [thread overview]
Message-ID: <ZDaBwLivCo9yRx/s@cormorant.local> (raw)
In-Reply-To: <b05fa5da-436f-7a49-7da0-3d17a13408b1@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]
On Apr 12 11:54, Philippe Mathieu-Daudé wrote:
> On 11/4/23 21:04, Klaus Jensen wrote:
> > From: Klaus Jensen <k.jensen@samsung.com>
> >
> > The iocb (and the allocated memory to hold LBA ranges) leaks if reading
> > the LBA ranges fails.
> >
> > Fix this by adding a free and an unref of the iocb.
> >
> > Reported-by: Coverity (CID 1508281)
> > Fixes: d7d1474fd85d ("hw/nvme: reimplement dsm to allow cancellation")
> > Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> > ---
> > hw/nvme/ctrl.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > index 8b7be1420912..ac24eeb5ed5a 100644
> > --- a/hw/nvme/ctrl.c
> > +++ b/hw/nvme/ctrl.c
> > @@ -2619,6 +2619,9 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
> > status = nvme_h2c(n, (uint8_t *)iocb->range, sizeof(NvmeDsmRange) * nr,
> > req);
> > if (status) {
> > + g_free(iocb->range);
> > + qemu_aio_unref(iocb);
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
> I note the qemu_aio_FOO() functions are not documented.
>
As-in, "you are not supposed to use them" or "this should be documented
at some point"?
Thanks for your reviews Philippe, you're a life-saver :)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-04-12 10:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 19:04 [PATCH 0/2] hw/nvme: coverity fixes Klaus Jensen
2023-04-11 19:04 ` [PATCH 1/2] hw/nvme: fix memory leak in fdp ruhid parsing Klaus Jensen
2023-04-12 9:47 ` Philippe Mathieu-Daudé
2023-04-11 19:04 ` [PATCH 2/2] hw/nvme: fix memory leak in nvme_dsm Klaus Jensen
2023-04-12 9:54 ` Philippe Mathieu-Daudé
2023-04-12 10:02 ` Klaus Jensen [this message]
2023-04-12 9:40 ` [PATCH 0/2] hw/nvme: coverity fixes Klaus Jensen
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=ZDaBwLivCo9yRx/s@cormorant.local \
--to=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).