|
|
26ccd9 |
From 367593e7b602fd490baf22a26887c09877e75c14 Mon Sep 17 00:00:00 2001
|
|
|
26ccd9 |
From: Alison Schofield <alison.schofield@intel.com>
|
|
|
26ccd9 |
Date: Thu, 3 Mar 2022 16:54:23 -0800
|
|
|
26ccd9 |
Subject: [PATCH 145/217] cxl/list: tidy the error path in add_cxl_decoder()
|
|
|
26ccd9 |
|
|
|
26ccd9 |
Static analysis reported this NULL pointer dereference during
|
|
|
26ccd9 |
cleanup on error in add_cxl_decoder().
|
|
|
26ccd9 |
|
|
|
26ccd9 |
Link: https://lore.kernel.org/r/20220304005423.1054282-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 | 8 +++++---
|
|
|
26ccd9 |
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
|
26ccd9 |
|
|
|
26ccd9 |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
|
26ccd9 |
index f111d86..1782f42 100644
|
|
|
26ccd9 |
--- a/cxl/lib/libcxl.c
|
|
|
26ccd9 |
+++ b/cxl/lib/libcxl.c
|
|
|
26ccd9 |
@@ -919,11 +919,11 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
|
|
|
26ccd9 |
|
|
|
26ccd9 |
decoder->dev_path = strdup(cxldecoder_base);
|
|
|
26ccd9 |
if (!decoder->dev_path)
|
|
|
26ccd9 |
- goto err;
|
|
|
26ccd9 |
+ goto err_decoder;
|
|
|
26ccd9 |
|
|
|
26ccd9 |
decoder->dev_buf = calloc(1, strlen(cxldecoder_base) + 50);
|
|
|
26ccd9 |
if (!decoder->dev_buf)
|
|
|
26ccd9 |
- goto err;
|
|
|
26ccd9 |
+ goto err_decoder;
|
|
|
26ccd9 |
decoder->buf_len = strlen(cxldecoder_base) + 50;
|
|
|
26ccd9 |
|
|
|
26ccd9 |
sprintf(path, "%s/start", cxldecoder_base);
|
|
|
26ccd9 |
@@ -1024,10 +1024,12 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
|
|
|
26ccd9 |
list_add(&port->decoders, &decoder->list);
|
|
|
26ccd9 |
|
|
|
26ccd9 |
return decoder;
|
|
|
26ccd9 |
-err:
|
|
|
26ccd9 |
+
|
|
|
26ccd9 |
+err_decoder:
|
|
|
26ccd9 |
free(decoder->dev_path);
|
|
|
26ccd9 |
free(decoder->dev_buf);
|
|
|
26ccd9 |
free(decoder);
|
|
|
26ccd9 |
+err:
|
|
|
26ccd9 |
free(path);
|
|
|
26ccd9 |
return NULL;
|
|
|
26ccd9 |
}
|
|
|
26ccd9 |
--
|
|
|
26ccd9 |
2.27.0
|
|
|
26ccd9 |
|