diff options
author | YueHaibing <yuehaibing@huawei.com> | 2018-09-18 16:46:38 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-09-19 06:11:43 +0300 |
commit | 381897798a94065ffcad0772eecdc6b04a7ff23d (patch) | |
tree | bfc86186fb6cc7065f1a5bebd2a34d8751da5d94 /net/smc/smc_clc.c | |
parent | 71d117f527425e2d6a5029e8365d82a8d2d6916a (diff) | |
download | linux-381897798a94065ffcad0772eecdc6b04a7ff23d.tar.xz |
net/smc: fix sizeof to int comparison
Comparing an int to a size, which is unsigned, causes the int to become
unsigned, giving the wrong result. kernel_sendmsg can return a negative
error code.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc/smc_clc.c')
-rw-r--r-- | net/smc/smc_clc.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index 83aba9ade060..52241d679cc9 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -446,14 +446,12 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type, vec[i++].iov_len = sizeof(trl); /* due to the few bytes needed for clc-handshake this cannot block */ len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen); - if (len < sizeof(pclc)) { - if (len >= 0) { - reason_code = -ENETUNREACH; - smc->sk.sk_err = -reason_code; - } else { - smc->sk.sk_err = smc->clcsock->sk->sk_err; - reason_code = -smc->sk.sk_err; - } + if (len < 0) { + smc->sk.sk_err = smc->clcsock->sk->sk_err; + reason_code = -smc->sk.sk_err; + } else if (len < (int)sizeof(pclc)) { + reason_code = -ENETUNREACH; + smc->sk.sk_err = -reason_code; } return reason_code; |