Skip to contentSkip to conversation

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

PATCH New [email protected] 1 participant 1 message Mar 4, 2022 libnvdimm: non-volatile memory device

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 cxl/list: always free the path var in add_cxl_decoder()

From: Alison Schofield <[email protected]>

Static analysis reported a resource leak where the 'path' variable was not always freed before returns.

Fixes 46564977afb7 ("cxl/list: Add decoder support")
---
 cxl/lib/libcxl.c | 2 ++
 1 file changed, 2 insertions(+)
cxl/lib/libcxl.c +2 -0
index daa2bbc5a299..aad7559daba2 100644
@@ -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

Signature · 1 line
2.31.1