From: Fan Ni Date: Mon, 7 Nov 2022 21:22:31 +0000 (+0000) Subject: cxl/region: Fix memdev reuse check X-Git-Tag: v6.0.18~175 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4327084b4b8ead300511138a9a641ddadccc7de;p=thirdparty%2Fkernel%2Fstable.git cxl/region: Fix memdev reuse check commit f04facfb993de47e2133b2b842d72b97b1c50162 upstream. Due to a typo, the check of whether or not a memdev has already been used as a target for the region (above code piece) will always be skipped. Given a memdev with more than one HDM decoder, an interleaved region can be created that maps multiple HPAs to the same DPA. According to CXL spec 3.0 8.1.3.8.4, "Aliasing (mapping more than one Host Physical Address (HPA) to a single Device Physical Address) is forbidden." Fix this by using existing iterator for memdev reuse check. Cc: Fixes: 384e624bb211 ("cxl/region: Attach endpoint decoders") Signed-off-by: Fan Ni Link: https://lore.kernel.org/r/20221107212153.745993-1-fan.ni@samsung.com Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 78344e4d4215b..dbf3413aa6178 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1225,7 +1225,7 @@ static int cxl_region_attach(struct cxl_region *cxlr, struct cxl_endpoint_decoder *cxled_target; struct cxl_memdev *cxlmd_target; - cxled_target = p->targets[pos]; + cxled_target = p->targets[i]; if (!cxled_target) continue;