Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3515500imm; Sun, 16 Sep 2018 20:58:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdafpUAB1NJUbqX6qncwwVoAUC6Lkenz7++feoNK4De+SECaPqZRnBOcb6LEti1nJ+a/hsRm X-Received: by 2002:a62:586:: with SMTP id 128-v6mr23990351pff.80.1537156691555; Sun, 16 Sep 2018 20:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537156691; cv=none; d=google.com; s=arc-20160816; b=Sg4L2t+jwcBQJNF5pG2Ns93ax1Cr2YWHPVpMYZQogK3xYrMc76n1QHWEluN5WkWbgk yrMe4Iv7bJkVRj9K4r4Mce69ESF65+8/3VaEEOHvCUwFhlbE03994u1CDGMG+xDemiah iAZJjNJAtb/d5R/70J5K9QdVqCejb0BEGUqTO8Sd5U4Eq1Ay4BF4v9+oNk0dYNw2GWG6 IHbAE2ZC78FXUVk118/Bc4y4n4coqqLNOhJNyZ4aJLjcC6R8YAAFvNmm5IzUvUOiYBeO n3qgDkZYeAXDvfOT0XuCSFmaYM45mxfFHvwNhXSJN5oYSi0hwk1UypYqZHzFT94x7yO0 VCug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=1YmB3witDXj193gvZwksVI0sSHkWGiUmuo6lp7+QVAQ=; b=ti9q581BBlFGWibUJwhmAkFkRkSk71uQ8fN8eDS155uc5/jh5fCw3GPIn7I1V4P3zc wcLDQiwVt1h/djPdnWMBtZInhx6EoTx01AdKB4sLH+/KcjAtCjcSM3/xWnywhc4NKdQe SOlpZcD7yK4wud7IIHb0uqXADzQvNgXHWI/1CFvDBct921MT+p4aCzKrBFAWynoaY7CV BSp9QAQ8SxSK5mlPAOsRdLPZRa/ueIgdUDJmB7deanX4GmSMMadX5cHnxiJK5z13I/V9 db8hVqOQMQPamRJbzuSO7PvU0P1nBo8msUa2NHvR72wmNRaXzAPZv4pDPOtZHQj4amBY y+yw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16-v6si14213719plr.343.2018.09.16.20.57.55; Sun, 16 Sep 2018 20:58:11 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728081AbeIQJXS (ORCPT + 99 others); Mon, 17 Sep 2018 05:23:18 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:48203 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726169AbeIQJXR (ORCPT ); Mon, 17 Sep 2018 05:23:17 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 73BD6E6167771; Mon, 17 Sep 2018 11:57:44 +0800 (CST) Received: from [127.0.0.1] (10.177.31.96) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.399.0; Mon, 17 Sep 2018 11:57:41 +0800 Subject: Re: [PATCH net-next] net/smc: cast sizeof to int for comparison To: Andreas Schwab References: <20180915100036.20100-1-yuehaibing@huawei.com> <87zhwj6liz.fsf@igel.home> CC: , , , , From: YueHaibing Message-ID: Date: Mon, 17 Sep 2018 11:57:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <87zhwj6liz.fsf@igel.home> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/9/15 19:35, Andreas Schwab wrote: > On Sep 15 2018, YueHaibing wrote: > >> 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 >> --- >> net/smc/smc_clc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c >> index 83aba9a..fd0f5ce 100644 >> --- a/net/smc/smc_clc.c >> +++ b/net/smc/smc_clc.c >> @@ -446,7 +446,7 @@ 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 < (int)sizeof(pclc)) { >> if (len >= 0) { >> reason_code = -ENETUNREACH; >> smc->sk.sk_err = -reason_code; > > It would perhaps be better to handle len < 0 first. That need refactor the err hangding, is worth doing it? > > Andreas. >