aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlison Schofield <alison.schofield@intel.com>2022-03-03 16:54:23 -0800
committerVishal Verma <vishal.l.verma@intel.com>2022-03-04 01:07:56 -0700
commit367593e7b602fd490baf22a26887c09877e75c14 (patch)
treefb9c2a0c34100c3fc9f4ab3bb628c3b0648b57c9
parent057ca6fc2ce63625236bf00e795e0847e6508ed8 (diff)
cxl/list: tidy the error path in add_cxl_decoder()
Static analysis reported this NULL pointer dereference during cleanup on error in add_cxl_decoder(). Link: https://lore.kernel.org/r/20220304005423.1054282-1-alison.schofield@intel.com Fixes: 46564977afb7 ("cxl/list: Add decoder support") Signed-off-by: Alison Schofield <alison.schofield@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
-rw-r--r--cxl/lib/libcxl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index f111d868..1782f423 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -919,11 +919,11 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
decoder->dev_path = strdup(cxldecoder_base);
if (!decoder->dev_path)
- goto err;
+ goto err_decoder;
decoder->dev_buf = calloc(1, strlen(cxldecoder_base) + 50);
if (!decoder->dev_buf)
- goto err;
+ goto err_decoder;
decoder->buf_len = strlen(cxldecoder_base) + 50;
sprintf(path, "%s/start", cxldecoder_base);
@@ -1024,10 +1024,12 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base)
list_add(&port->decoders, &decoder->list);
return decoder;
-err:
+
+err_decoder:
free(decoder->dev_path);
free(decoder->dev_buf);
free(decoder);
+err:
free(path);
return NULL;
}