aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2023-04-11 20:34:11 +0200
committerKlaus Jensen <k.jensen@samsung.com>2023-04-12 12:03:02 +0200
commitcb16e5c76f4e719e6d0f9fd2cb6cfe6e6c17fed9 (patch)
tree942d1250c1b7ac7c996e663a239332155ef8f4e1 /hw
parent6c50845a9183610cfd4cfffd48dfc704cd340882 (diff)
hw/nvme: fix memory leak in fdp ruhid parsing
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") Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/nvme/ns.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c
index cfac960dcf..547c0b1543 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;