From patchwork Wed Oct 28 11:44:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 11864099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6230914B4 for ; Wed, 28 Oct 2020 23:33:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C3CA207CD for ; Wed, 28 Oct 2020 23:33:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390528AbgJ1XdH (ORCPT ); Wed, 28 Oct 2020 19:33:07 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59476 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726859AbgJ1XdG (ORCPT ); Wed, 28 Oct 2020 19:33:06 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kXjsA-0002fs-SB; Wed, 28 Oct 2020 11:44:10 +0000 From: Colin King To: Trond Myklebust , Anna Schumaker , "J . Bruce Fields" , Chuck Lever , "David S . Miller" , Jakub Kicinski , Artur Molchanov , linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] net/sunrpc: fix unsigned size_t comparison to less than zero Date: Wed, 28 Oct 2020 11:44:10 +0000 Message-Id: <20201028114410.108759-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Colin Ian King Currently the check for *lenp < 0 is always true since the type is a size_t and can never be negative. Fix this by casting it to ssize_t. Addresses-Coverity: ("Unsigned compared against 0") Fixes: c09f56b8f68d ("net/sunrpc: Fix return value for sysctl sunrpc.transports") Signed-off-by: Colin Ian King --- net/sunrpc/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index a18b36b5422d..bb62badef6bc 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -72,7 +72,7 @@ static int proc_do_xprt(struct ctl_table *table, int write, len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); - if (*lenp < 0) { + if ((ssize_t)*lenp < 0) { *lenp = 0; return -EINVAL; }