NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
* [ndctl PATCH] cxl/list: always free the path var in add_cxl_decoder()
@ 2022-03-04  1:36 alison.schofield
  0 siblings, 0 replies; only message in thread
From: alison.schofield @ 2022-03-04  1:36 UTC (permalink / raw)
  To: Vishal Verma, Dan Williams; +Cc: Alison Schofield, nvdimm

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-04  1:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04  1:36 [ndctl PATCH] cxl/list: always free the path var in add_cxl_decoder() alison.schofield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox