anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame 0214-cxl-region-fix-a-dereferecnce-after-NULL-check.patch

Jeff Moyer 2c91dc
From cc2766399882001880a899e723c7bd968e60f100 Mon Sep 17 00:00:00 2001
Jeff Moyer 2c91dc
From: Vishal Verma <vishal.l.verma@intel.com>
Jeff Moyer 2c91dc
Date: Tue, 23 Aug 2022 01:45:25 -0600
Jeff Moyer 2c91dc
Subject: [PATCH 214/217] cxl/region: fix a dereferecnce after NULL check
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
A NULL check in region_action() implies that 'decoder' might be NULL, but
Jeff Moyer 2c91dc
later we dereference it during cxl_decoder_foreach(). The NULL check is
Jeff Moyer 2c91dc
valid because it was the filter result being checked, however, while
Jeff Moyer 2c91dc
doing this, the original 'decoder' variable was being clobbered.
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
Check the filter results independently of the original decoder variable.
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
Link: https://lore.kernel.org/r/20220823074527.404435-2-vishal.l.verma@intel.com
Jeff Moyer 2c91dc
Cc: Dan Williams <dan.j.williams@intel.com>
Jeff Moyer 2c91dc
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Jeff Moyer 2c91dc
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Jeff Moyer 2c91dc
---
Jeff Moyer 2c91dc
 cxl/region.c | 5 ++---
Jeff Moyer 2c91dc
 1 file changed, 2 insertions(+), 3 deletions(-)
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
diff --git a/cxl/region.c b/cxl/region.c
Jeff Moyer 2c91dc
index a30313c..334fcc2 100644
Jeff Moyer 2c91dc
--- a/cxl/region.c
Jeff Moyer 2c91dc
+++ b/cxl/region.c
Jeff Moyer 2c91dc
@@ -686,9 +686,8 @@ static int region_action(int argc, const char **argv, struct cxl_ctx *ctx,
Jeff Moyer 2c91dc
 			continue;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 		cxl_decoder_foreach (port, decoder) {
Jeff Moyer 2c91dc
-			decoder = util_cxl_decoder_filter(decoder,
Jeff Moyer 2c91dc
-							  param.root_decoder);
Jeff Moyer 2c91dc
-			if (!decoder)
Jeff Moyer 2c91dc
+			if (!util_cxl_decoder_filter(decoder,
Jeff Moyer 2c91dc
+						     param.root_decoder))
Jeff Moyer 2c91dc
 				continue;
Jeff Moyer 2c91dc
 			rc = decoder_region_action(p, decoder, action, count);
Jeff Moyer 2c91dc
 			if (rc)
Jeff Moyer 2c91dc
-- 
Jeff Moyer 2c91dc
2.27.0
Jeff Moyer 2c91dc