提交 38189779 编写于 作者: Y YueHaibing 提交者: David S. Miller

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: NYueHaibing <yuehaibing@huawei.com>
Signed-off-by: NUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 71d117f5
...@@ -446,14 +446,12 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type, ...@@ -446,14 +446,12 @@ int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,
vec[i++].iov_len = sizeof(trl); vec[i++].iov_len = sizeof(trl);
/* due to the few bytes needed for clc-handshake this cannot block */ /* due to the few bytes needed for clc-handshake this cannot block */
len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen); len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen);
if (len < sizeof(pclc)) { if (len < 0) {
if (len >= 0) { smc->sk.sk_err = smc->clcsock->sk->sk_err;
reason_code = -ENETUNREACH; reason_code = -smc->sk.sk_err;
smc->sk.sk_err = -reason_code; } else if (len < (int)sizeof(pclc)) {
} else { reason_code = -ENETUNREACH;
smc->sk.sk_err = smc->clcsock->sk->sk_err; smc->sk.sk_err = -reason_code;
reason_code = -smc->sk.sk_err;
}
} }
return reason_code; return reason_code;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册