Blame SOURCES/0146-cxl-list-always-free-the-path-var-in-add_cxl_decoder.patch

2eb93d
From 7564aeeae7bc8c3813bd80676769bd11a1055ca0 Mon Sep 17 00:00:00 2001
2eb93d
From: Alison Schofield <alison.schofield@intel.com>
2eb93d
Date: Thu, 3 Mar 2022 17:36:43 -0800
2eb93d
Subject: [PATCH 146/217] cxl/list: always free the path var in
2eb93d
 add_cxl_decoder()
2eb93d
2eb93d
Static analysis reported a resource leak where the 'path' variable was
2eb93d
not always freed before returns.
2eb93d
2eb93d
Link: https://lore.kernel.org/r/20220304013643.1054605-1-alison.schofield@intel.com
2eb93d
Fixes: 46564977afb7 ("cxl/list: Add decoder support")
2eb93d
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 cxl/lib/libcxl.c | 2 ++
2eb93d
 1 file changed, 2 insertions(+)
2eb93d
2eb93d
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
2eb93d
index 1782f42..59e1644 100644
2eb93d
--- a/cxl/lib/libcxl.c
2eb93d
+++ b/cxl/lib/libcxl.c
2eb93d
@@ -1018,11 +1018,13 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
2eb93d
 	cxl_decoder_foreach(port, decoder_dup)
2eb93d
 		if (decoder_dup->id == decoder->id) {
2eb93d
 			free_decoder(decoder, NULL);
2eb93d
+			free(path);
2eb93d
 			return decoder_dup;
2eb93d
 		}
2eb93d
 
2eb93d
 	list_add(&port->decoders, &decoder->list);
2eb93d
 
2eb93d
+	free(path);
2eb93d
 	return decoder;
2eb93d
 
2eb93d
 err_decoder:
2eb93d
-- 
2eb93d
2.27.0
2eb93d