Skip to content

Commit 4cf67d3

Browse files
leitaostellarhopper
authored andcommitted
cxl/acpi: Fix a use-after-free in cxl_parse_cfmws()
KASAN and KFENCE detected an user-after-free in the CXL driver. This happens in the cxl_decoder_add() fail path. KASAN prints the following error: BUG: KASAN: slab-use-after-free in cxl_parse_cfmws (drivers/cxl/acpi.c:299) This happens in cxl_parse_cfmws(), where put_device() is called, releasing cxld, which is accessed later. Use the local variables in the dev_err() instead of pointing to the released memory. Since the dev_err() is printing a resource, change the open coded print format to use the %pr format specifier. Fixes: e50fe01 ("cxl/core: Drop ->platform_res attribute for root decoders") Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://lore.kernel.org/r/20230714093146.2253438-1-leitao@debian.org Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
1 parent 004ff1b commit 4cf67d3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/cxl/acpi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg,
296296
else
297297
rc = cxl_decoder_autoremove(dev, cxld);
298298
if (rc) {
299-
dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
300-
cxld->hpa_range.start, cxld->hpa_range.end);
299+
dev_err(dev, "Failed to add decode range: %pr", res);
301300
return 0;
302301
}
303302
dev_dbg(dev, "add: %s node: %d range [%#llx - %#llx]\n",

0 commit comments

Comments
 (0)