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

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