From: Daniel Wagner Date: Wed, 20 Dec 2023 07:26:16 +0000 (+0100) Subject: tree: do no free ns on error in nvme_ns_init X-Git-Tag: v1.7.1~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=09391da861cefdb0134a6ea95872c454fce0f14c;p=users%2Fsagi%2Flibnvme.git tree: do no free ns on error in nvme_ns_init 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 --- 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);