]>
Commit | Line | Data |
---|---|---|
345c7afc SL |
1 | From 523e6b4118c1e4d3e13bc10db6d7007d28a1f637 Mon Sep 17 00:00:00 2001 |
2 | From: Arnd Bergmann <arnd@arndb.de> | |
3 | Date: Wed, 17 Apr 2019 18:29:13 +0200 | |
4 | Subject: s390: ctcm: fix ctcm_new_device error return code | |
5 | ||
6 | [ Upstream commit 27b141fc234a3670d21bd742c35d7205d03cbb3a ] | |
7 | ||
8 | clang points out that the return code from this function is | |
9 | undefined for one of the error paths: | |
10 | ||
11 | ../drivers/s390/net/ctcm_main.c:1595:7: warning: variable 'result' is used uninitialized whenever 'if' condition is true | |
12 | [-Wsometimes-uninitialized] | |
13 | if (priv->channel[direction] == NULL) { | |
14 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
15 | ../drivers/s390/net/ctcm_main.c:1638:9: note: uninitialized use occurs here | |
16 | return result; | |
17 | ^~~~~~ | |
18 | ../drivers/s390/net/ctcm_main.c:1595:3: note: remove the 'if' if its condition is always false | |
19 | if (priv->channel[direction] == NULL) { | |
20 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
21 | ../drivers/s390/net/ctcm_main.c:1539:12: note: initialize the variable 'result' to silence this warning | |
22 | int result; | |
23 | ^ | |
24 | ||
25 | Make it return -ENODEV here, as in the related failure cases. | |
26 | gcc has a known bug in underreporting some of these warnings | |
27 | when it has already eliminated the assignment of the return code | |
28 | based on some earlier optimization step. | |
29 | ||
30 | Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> | |
31 | Signed-off-by: Arnd Bergmann <arnd@arndb.de> | |
32 | Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> | |
33 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
34 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
35 | --- | |
36 | drivers/s390/net/ctcm_main.c | 1 + | |
37 | 1 file changed, 1 insertion(+) | |
38 | ||
39 | diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c | |
40 | index 05c37d6d4afef..a31821d946775 100644 | |
41 | --- a/drivers/s390/net/ctcm_main.c | |
42 | +++ b/drivers/s390/net/ctcm_main.c | |
43 | @@ -1595,6 +1595,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) | |
44 | if (priv->channel[direction] == NULL) { | |
45 | if (direction == CTCM_WRITE) | |
46 | channel_free(priv->channel[CTCM_READ]); | |
47 | + result = -ENODEV; | |
48 | goto out_dev; | |
49 | } | |
50 | priv->channel[direction]->netdev = dev; | |
51 | -- | |
52 | 2.20.1 | |
53 |