From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>,
qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>
Subject: [PATCH 1/2] hw/nvme: fix memory leak in fdp ruhid parsing
Date: Tue, 11 Apr 2023 21:04:47 +0200 [thread overview]
Message-ID: <20230411190448.64863-2-its@irrelevant.dk> (raw)
In-Reply-To: <20230411190448.64863-1-its@irrelevant.dk>
From: Klaus Jensen <k.jensen@samsung.com>
Coverity reports a memory leak of memory when parsing ruhids at
namespace initialization. Since this is just working memory, not needed
beyond the scope of the functions, fix this by adding a g_autofree
annotation.
Reported-by: Coverity (CID 1507979)
Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ns.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c
index cfac960dcf39..547c0b154312 100644
--- a/hw/nvme/ns.c
+++ b/hw/nvme/ns.c
@@ -399,7 +399,8 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp)
NvmeEnduranceGroup *endgrp = ns->endgrp;
NvmeRuHandle *ruh;
uint8_t lbafi = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
- unsigned int *ruhid, *ruhids;
+ g_autofree unsigned int *ruhids = NULL;
+ unsigned int *ruhid;
char *r, *p, *token;
uint16_t *ph;
--
2.39.2
next prev parent reply other threads:[~2023-04-11 19:06 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 ` Klaus Jensen [this message]
2023-04-12 9:47 ` [PATCH 1/2] hw/nvme: fix memory leak in fdp ruhid parsing 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
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=20230411190448.64863-2-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=peter.maydell@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).