anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame 0145-cxl-list-tidy-the-error-path-in-add_cxl_decoder.patch

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