diff mbox series

[ndctl] cxl/list: always free the path var in add_cxl_decoder()

Message ID 20220304013643.1054605-1-alison.schofield@intel.com (mailing list archive)
State Accepted
Commit 7564aeeae7bc8c3813bd80676769bd11a1055ca0
Headers show
Series [ndctl] cxl/list: always free the path var in add_cxl_decoder() | expand

Commit Message

Alison Schofield March 4, 2022, 1:36 a.m. UTC
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(+)


base-commit: 3b5fb8b6428dfaab39bab58d67412427f514c1f4
diff mbox series

Patch

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);