Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 27b141f

Browse files
arndbdavem330
authored andcommitted
s390: ctcm: fix ctcm_new_device error return code
clang points out that the return code from this function is undefined for one of the error paths: ../drivers/s390/net/ctcm_main.c:1595:7: warning: variable 'result' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (priv->channel[direction] == NULL) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/s390/net/ctcm_main.c:1638:9: note: uninitialized use occurs here return result; ^~~~~~ ../drivers/s390/net/ctcm_main.c:1595:3: note: remove the 'if' if its condition is always false if (priv->channel[direction] == NULL) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/s390/net/ctcm_main.c:1539:12: note: initialize the variable 'result' to silence this warning int result; ^ Make it return -ENODEV here, as in the related failure cases. gcc has a known bug in underreporting some of these warnings when it has already eliminated the assignment of the return code based on some earlier optimization step. Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Julian Wiedmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d003d77 commit 27b141f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/s390/net/ctcm_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)
15951595
if (priv->channel[direction] == NULL) {
15961596
if (direction == CTCM_WRITE)
15971597
channel_free(priv->channel[CTCM_READ]);
1598+
result = -ENODEV;
15981599
goto out_dev;
15991600
}
16001601
priv->channel[direction]->netdev = dev;

0 commit comments

Comments
 (0)