From: Alison Schofield <alison.schofi...@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.schofi...@intel.com>
---
 cxl/lib/libcxl.c | 2 ++
 1 file changed, 2 insertions(+)

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

base-commit: 3b5fb8b6428dfaab39bab58d67412427f514c1f4
-- 
2.31.1


Reply via email to