Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5254867imm; Tue, 18 Sep 2018 06:47:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZC2tIwZdMbOfbGANjMe4fpiPAgGbHdGI0wFWQ33bUtX3X4fntdN3NOqisR703G39i94+GO X-Received: by 2002:a65:594b:: with SMTP id g11-v6mr27990443pgu.260.1537278469651; Tue, 18 Sep 2018 06:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537278469; cv=none; d=google.com; s=arc-20160816; b=Vp0eWUs75XXXJTfulExQYpa9RkSwqTXdZtLh84VWyyPATHRMFowAKpZj/TSSEKSxe7 XNaVZRiWxi5qzSwBixne8fwrwOmEkfhcmsbSjOxsBM5rjXZ1YjFdqa8QsoZwD60eUzC2 Eu/Ay6Oq8lFgorAEfSfaTUPT4pnK5sol+DtTBl1bElZA9CKWo4+L+3QapnVbnItKbbak /q2fSeE3mxkYcHq+483jCd2OuLjNfTbbM+fofxUDzgGq7yIL060WdqAuWW0nVzRvprDN Wr47EDsIW6D8mFiLUasIKwUVSc2GCTFynC3mXNb/zcvN1Y6R3jNR/FM4x99B24BUgLPz vezA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=MVABvg5OUh7inUPbfCbIvmAcVhrnBoHaX1udp2brXRc=; b=bZNoHQvxaG9GUFmnqjfDETKLnjPtiPq3xTC00HwjXDUoiJfX/h46ci4DGLuc7IkUmp 6p7t+epi/OLthB5UTg0oVo8Meq42DiC5pjkTC4J20S2u/71qcSNWKZ4uFK8UhlVhHxzK NmJfaAOm+blUToZyCBwrkGBTK6XHAXVnS85ABVw/NbjGMKTB+luobbKgbKvpmqpoR2wW uCFq+H//d2zkwfBqu4xTioJK9IhCOEENl77Rhg/VNFDFOiDOsONxXXzBPLTnL0WPQ3bP xtuE6I+v9oFc2TxzA35HcHCnAcY3CcyvxVzQQzdlUzmFcmNgcdmpyhqPUTdRH3t7VZD4 TRJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r39-v6si18279686pld.218.2018.09.18.06.47.34; Tue, 18 Sep 2018 06:47:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730031AbeIRTTg (ORCPT + 99 others); Tue, 18 Sep 2018 15:19:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34054 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729647AbeIRTTf (ORCPT ); Tue, 18 Sep 2018 15:19:35 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8IDdPcF084816 for ; Tue, 18 Sep 2018 09:46:54 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mk1yehsjv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 18 Sep 2018 09:46:54 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Sep 2018 14:46:52 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 18 Sep 2018 14:46:48 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8IDklm359048056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Sep 2018 13:46:47 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7F4811C04A; Tue, 18 Sep 2018 16:46:32 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DD8011C058; Tue, 18 Sep 2018 16:46:32 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 18 Sep 2018 16:46:32 +0100 (BST) From: Ursula Braun To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, raspl@linux.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH net 5/5] net/smc: fix sizeof to int comparison Date: Tue, 18 Sep 2018 15:46:38 +0200 X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180918134638.90271-1-ubraun@linux.ibm.com> References: <20180918134638.90271-1-ubraun@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18091813-0012-0000-0000-000002AA53CB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091813-0013-0000-0000-000020DEAD2A Message-Id: <20180918134638.90271-6-ubraun@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-18_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=630 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809180139 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing 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 Signed-off-by: Ursula Braun --- net/smc/smc_clc.c | 14 ++++++-------- 1 file 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; -- 2.16.4