From 09391da861cefdb0134a6ea95872c454fce0f14c Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 20 Dec 2023 08:26:16 +0100 Subject: [PATCH] tree: do no free ns on error in nvme_ns_init MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The ns pointer is owned by the caller not by nvme_ns_init, thus we can't just free it on error. Fixes: 7959f52960fd ("tree: read all attributes from sysfs when available") Reported-by: Tomasz Kłoczko Signed-off-by: Daniel Wagner --- src/nvme/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 5d1d3bb2..07a3c532 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -2473,7 +2473,7 @@ static int nvme_ns_init(const char *path, struct nvme_ns *ns) ret = nvme_ns_identify(ns, id); if (ret) - free(ns); + return ret; nvme_id_ns_flbas_to_lbaf_inuse(id->flbas, &flbas); ns->lba_count = le64_to_cpu(id->nsze); -- 2.50.1