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

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