diff options
author | Arnd Bergmann <[email protected]> | 2023-02-13 11:12:11 +0100 |
---|---|---|
committer | Dan Williams <[email protected]> | 2023-02-14 08:36:34 -0800 |
commit | 7abcb0b10668eaf3c174ff383f3b2a7a8c95fb34 (patch) | |
tree | 317ee61cbfd6525da6f19b0bcf552bee84449d2c | |
parent | 09d09e04d2fcf88c4620dd28097e0e2a8f720eac (diff) |
cxl: avoid returning uninitialized error code
The new cxl_add_to_region() function returns an uninitialized
value on success:
drivers/cxl/core/region.c:2628:6: error: variable 'rc' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (IS_ERR(cxlr)) {
^~~~~~~~~~~~
drivers/cxl/core/region.c:2654:9: note: uninitialized use occurs here
return rc;
Simplify the logic to have the rc variable always initialized in the
same place.
Fixes: a32320b71f08 ("cxl/region: Add region autodiscovery")
Signed-off-by: Arnd Bergmann <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dan Williams <[email protected]>
-rw-r--r-- | drivers/cxl/core/region.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 91bb9ac881ff..8ba71ca4135c 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2623,10 +2623,9 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled) cxlr = to_cxl_region(region_dev); mutex_unlock(&cxlrd->range_lock); - if (IS_ERR(cxlr)) { - rc = PTR_ERR(cxlr); + rc = PTR_ERR_OR_ZERO(cxlr); + if (rc) goto out; - } attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE); |