]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/s390-ctcm-fix-ctcm_new_device-error-return-code.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / s390-ctcm-fix-ctcm_new_device-error-return-code.patch
CommitLineData
345c7afc
SL
1From 523e6b4118c1e4d3e13bc10db6d7007d28a1f637 Mon Sep 17 00:00:00 2001
2From: Arnd Bergmann <arnd@arndb.de>
3Date: Wed, 17 Apr 2019 18:29:13 +0200
4Subject: s390: ctcm: fix ctcm_new_device error return code
5
6[ Upstream commit 27b141fc234a3670d21bd742c35d7205d03cbb3a ]
7
8clang points out that the return code from this function is
9undefined 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
25Make it return -ENODEV here, as in the related failure cases.
26gcc has a known bug in underreporting some of these warnings
27when it has already eliminated the assignment of the return code
28based on some earlier optimization step.
29
30Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
31Signed-off-by: Arnd Bergmann <arnd@arndb.de>
32Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
33Signed-off-by: David S. Miller <davem@davemloft.net>
34Signed-off-by: Sasha Levin <sashal@kernel.org>
35---
36 drivers/s390/net/ctcm_main.c | 1 +
37 1 file changed, 1 insertion(+)
38
39diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
40index 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--
522.20.1
53