From: alison.schofield@intel.com
To: Vishal Verma <vishal.l.verma@intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>, nvdimm@lists.linux.dev
Subject: [ndctl PATCH] cxl/list: always free the path var in add_cxl_decoder()
Date: Thu, 3 Mar 2022 17:36:43 -0800 [thread overview]
Message-ID: <20220304013643.1054605-1-alison.schofield@intel.com> (raw)
From: Alison Schofield <alison.schofield@intel.com>
Static analysis reported a resource leak where the 'path' variable was
not always freed before returns.
Fixes: 46564977afb7 ("cxl/list: Add decoder support")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
cxl/lib/libcxl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index daa2bbc5a299..aad7559daba2 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -1018,11 +1018,13 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
cxl_decoder_foreach(port, decoder_dup)
if (decoder_dup->id == decoder->id) {
free_decoder(decoder, NULL);
+ free(path);
return decoder_dup;
}
list_add(&port->decoders, &decoder->list);
+ free(path);
return decoder;
err:
free(decoder->dev_path);
base-commit: 3b5fb8b6428dfaab39bab58d67412427f514c1f4
--
2.31.1
reply other threads:[~2022-03-04 1:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220304013643.1054605-1-alison.schofield@intel.com \
--to=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/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