Commit 5e42bcbc authored by Dan Carpenter's avatar Dan Carpenter Committed by Dan Williams

cxl/region: decrement ->nr_targets on error in cxl_region_attach()

The ++ needs a match -- on the clean up path.  If the p->nr_targets
value gets to be more than 16 it leads to uninitialized data in
cxl_port_setup_targets().

drivers/cxl/core/region.c:995 cxl_port_setup_targets() error: uninitialized symbol 'eiw'.

Fixes: 27b3f8d1 ("cxl/region: Program target lists")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YuepCvUAoCtdpcoO@kiliSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c7e3548c
......@@ -1218,12 +1218,14 @@ static int cxl_region_attach(struct cxl_region *cxlr,
if (p->nr_targets == p->interleave_ways) {
rc = cxl_region_setup_targets(cxlr);
if (rc)
goto err;
goto err_decrement;
p->state = CXL_CONFIG_ACTIVE;
}
return 0;
err_decrement:
p->nr_targets--;
err:
for (iter = ep_port; !is_cxl_root(iter);
iter = to_cxl_port(iter->dev.parent))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment