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: 311299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F8B3C388F7 for ; Wed, 28 Oct 2020 23:33:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8E5C207BC for ; Wed, 28 Oct 2020 23:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390529AbgJ1XdH (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: netdev@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; }