summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2022-08-03 00:47:08 +0300
committerDan Williams <dan.j.williams@intel.com>2022-08-05 18:41:02 +0300
commit69c9961387f244077101de3ce4e272717617dc87 (patch)
tree9cad0128fbe4073b54a4a7bb7d9b7ce0566d0f52 /drivers
parent8d428542571428fb68b5c41b092ae70d2fc2cd17 (diff)
downloadlinux-69c9961387f244077101de3ce4e272717617dc87.tar.xz
cxl/region: Fix region commit uninitialized variable warning
0day robot reports: drivers/cxl/core/region.c:196 cxl_region_decode_commit() error: uninitialized symbol 'rc'. The re-checking of loop termination conditions to determine "success" makes it hard to see that @rc is initialized in all cases. Remove those to make it explicit that @rc reflects a commit error and that the rest of logic is concerned with unwinding committed decoders. This change potentially results in cxl_region_decode_reset() being called with @count == 0 where it was not called before, but cxl_region_decode_reset() treats that as a nop. Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware") Reported-by: kernel test robot <lkp@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: http://lore.kernel.org/r/165951148105.967013.14191992449932268431.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cxl/core/region.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 25502c9c368c..addab74d24bb 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -159,7 +159,7 @@ static int cxl_region_decode_reset(struct cxl_region *cxlr, int count)
static int cxl_region_decode_commit(struct cxl_region *cxlr)
{
struct cxl_region_params *p = &cxlr->params;
- int i, rc;
+ int i, rc = 0;
for (i = 0; i < p->nr_targets; i++) {
struct cxl_endpoint_decoder *cxled = p->targets[i];
@@ -179,27 +179,23 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr)
break;
}
- /* success, all decoders up to the root are programmed */
- if (is_cxl_root(iter))
- continue;
+ if (rc) {
+ /* programming @iter failed, teardown */
+ for (ep = cxl_ep_load(iter, cxlmd); ep && iter;
+ iter = ep->next, ep = cxl_ep_load(iter, cxlmd)) {
+ cxl_rr = cxl_rr_load(iter, cxlr);
+ cxld = cxl_rr->decoder;
+ cxld->reset(cxld);
+ }
- /* programming @iter failed, teardown */
- for (ep = cxl_ep_load(iter, cxlmd); ep && iter;
- iter = ep->next, ep = cxl_ep_load(iter, cxlmd)) {
- cxl_rr = cxl_rr_load(iter, cxlr);
- cxld = cxl_rr->decoder;
- cxld->reset(cxld);
+ cxled->cxld.reset(&cxled->cxld);
+ goto err;
}
-
- cxled->cxld.reset(&cxled->cxld);
- if (i == 0)
- return rc;
- break;
}
- if (i >= p->nr_targets)
- return 0;
+ return 0;
+err:
/* undo the targets that were successfully committed */
cxl_region_decode_reset(cxlr, i);
return rc;