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

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