Skip to content

Commit 7abcb0b

Browse files
arndbdjbw
authored andcommitted
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: a32320b ("cxl/region: Add region autodiscovery") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20230213101220.3821689-1-arnd@kernel.org Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 09d09e0 commit 7abcb0b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/cxl/core/region.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,10 +2623,9 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled)
26232623
cxlr = to_cxl_region(region_dev);
26242624
mutex_unlock(&cxlrd->range_lock);
26252625

2626-
if (IS_ERR(cxlr)) {
2627-
rc = PTR_ERR(cxlr);
2626+
rc = PTR_ERR_OR_ZERO(cxlr);
2627+
if (rc)
26282628
goto out;
2629-
}
26302629

26312630
attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE);
26322631

0 commit comments

Comments
 (0)