Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3729390imm; Mon, 8 Oct 2018 08:36:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV63DX8TJFpYsVY+RFKgX96DzyIHL3/z8ep706eitLNHC+swX5RS+sP9D4/TyujugKb2r937H X-Received: by 2002:a17:902:1ab:: with SMTP id b40-v6mr24710551plb.82.1539013016233; Mon, 08 Oct 2018 08:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539013016; cv=none; d=google.com; s=arc-20160816; b=Waog0anJMiem10Grr/2+ATyCBWGrSLX/sMwbvYvS6OsrXbWGO96poXzkYZS0V8HhYg psVU8aWjjwOY/rMJEESwkx5rrhZzpb8Lv0xYBC66UxeGq1CLU8PbiWXIBnBh4V4myxJn tjAoHU3QSgAFp27e6JKoS/f0TnPSXW3aLs/mdjB5/y+PDzVzvsGbl5ARa3E2tuMyRvee bgsFNRiqg8ZDjfSJ1/5LOkJbzg6JJo31VOSFMr0zjV684EbKP6j89QH3IQQng99RGQmC cXD7fV7QhxSHuu0gATEybutC1j7afeMWkPNAfEHzY0ioZILyRJt2s3Uix3rRxMZUgsOe hVcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=yWCDlww540Sxy0uyafkTznvBiYSus49wB4PFJxvJsws=; b=yZBuxPc4xjJKNQmTBXWZhhN0mIz+F2NYhwbPSIlo1EedixSCRCOGJJjv5RAfbHPR45 Gsc+sDOqLnVy8FrdipeAOoNr334QRZW+doIaU/7XVNV8lwf/sf3aEoGmWfn6D2yJrFWX aOKGeJ+gGdlHwMbA7por7igH26zsHozP5y0FQtcwklQ79J7f9YA3NuVr313xExLfmqEc uLdVXJ/PuCrbSCs8KNfd7YKwBXl2TEVsePsOYWL9xyRuObroofh93McpILR6K7Gdt/Yx kGOcEmfuUYDHGsolFUicL9Lae2Zm0Dc2IeHkU5Bdg4k5nwaKbKw3BTxtFuaQiGPakcOd xGQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wrx3uomt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n73-v6si18848170pfh.96.2018.10.08.08.36.41; Mon, 08 Oct 2018 08:36:56 -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; dkim=pass header.i=@kernel.org header.s=default header.b=wrx3uomt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbeJHWsp (ORCPT + 99 others); Mon, 8 Oct 2018 18:48:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:56524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727478AbeJHWiL (ORCPT ); Mon, 8 Oct 2018 18:38:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4323B214FA; Mon, 8 Oct 2018 15:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012356; bh=322mZ2DJbQyK2ZQOB1qJyTphP12wA6q/XVuZ8ZPpUuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wrx3uomttNYy5TJM7P5AIX0XvNBCiUqTMHdEFD1F7vDJ793lGjJWxOt/hQqzZBEc9 2hL4oHWYqSjuDVp5hYdxwo74mgFJabfuJ5OP9DmkItWTOM6eqyM0keai7uO3nfhS8m Wye7bcs5ohkCGzUabPl5ZRD1E35CA091qXhC8/kU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: YueHaibing , Ursula Braun , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 31/58] net/smc: fix sizeof to int comparison Date: Mon, 8 Oct 2018 11:24:56 -0400 Message-Id: <20181008152523.70705-31-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing [ Upstream commit 381897798a94065ffcad0772eecdc6b04a7ff23d ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 ae5d168653ce..086157555ac3 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -405,14 +405,12 @@ int smc_clc_send_proposal(struct smc_sock *smc, 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.17.1