Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1452865rwb; Mon, 7 Nov 2022 01:39:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM5w20kTdurIbZg6kHvKvUtMvbq0GJ7D7FtWHfj7byXPt7sXp36l+f4NH3096EUnKxscSFEN X-Received: by 2002:a17:907:a05c:b0:7ad:f563:815d with SMTP id gz28-20020a170907a05c00b007adf563815dmr29343890ejc.371.1667813946676; Mon, 07 Nov 2022 01:39:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667813946; cv=none; d=google.com; s=arc-20160816; b=Ueafe8rKV8uwep+H7Z0S42EQYli5TuJ24r6xSENX03wMFaR0GbBV2LuWXYTzM+//7T 8/nhb10iLDKADeqHUeFnivmY3xPhO1Q1of/Ms5EjhtikX/EPn6N33aILRmcibewwMukr elqlEKL8mfhajOMNA51Wm3pFI25Kq6ZCfRF9sa4MnE/NcwOvn8KA+dBlk/+dt5bV7EuY SfW9RDvp+n3Iu5xEzJQ7y2qUbo3EWxRbbVXB6ZOzLN3PYehoMWXsGnRR1HUUjSbH6iLh PA8I9zhlSUhlHo2qTwpnseHPBV1AqBPafPewkv6YaMDBiuEr8uNsK+QxuBxk/8LFYxN/ htew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=l6zr+Gb9iB9K86VIPNWhdzDTlsWsfAxQuQRZtJaudHM=; b=f+fvPr7oJxuEchbEx1j+Pr2uUlaj4ccL0LTT7k3OHJh1zEumIz2tYEniZqN8TqeGiW DSBpiAz48aWfOEg4/daAnYbYeSfVFEyEJtquOYJL1hpoHCt/sziMDds1IppJu7gu4U6o 06Qkn+A8r/a2QeY4VrE1+IoyrXS/95FSOwezlLyPXraqgjengAX9cL9RD7ifrHgsqZII dWxfnqMjUkAF+wE7KIes0cKCAdNan/RLM7BuV3p5mBdkUTDm3132KOHSMFLsj4BM28qm THDVF6gJwQEo+VAnHkFMtmsT9zMInCWZaKoEn7yJRySA/KZNObqaQvWazLSxGHmPDzuq rAZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HIRQu2IR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a056402431400b00463c5d64f30si10745062edc.557.2022.11.07.01.38.42; Mon, 07 Nov 2022 01:39:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HIRQu2IR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231172AbiKGI4k (ORCPT + 95 others); Mon, 7 Nov 2022 03:56:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiKGI4i (ORCPT ); Mon, 7 Nov 2022 03:56:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1BBF15836; Mon, 7 Nov 2022 00:56:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9B85FB80E59; Mon, 7 Nov 2022 08:56:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51FF3C433D6; Mon, 7 Nov 2022 08:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667811395; bh=mRQqDDo7h2WtOH56vRgwnhYTYbCXcOsZBM0uKXEWQ+Y=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=HIRQu2IRF9Jddq2VZbtwVA7irRrBf0ivmSk6B0iqHD9LnZkrTxqOhB9w7cDYRxxeG UEjoq8H95pL9q8mW9zfyeAxwF3Qf0HezTTcaC744Z2i7FPBKs+w2nS9uPlwfdMopN2 XjpVI1Xf0cFru/UxK8Aeetl1LPAy9wdw9xSxg1HwZzqgvdzPdDEFgIZcFYjnwEFj7X R/2yQvK+mNv9SG5Tw0g7lfkwr2jc6/V/Xq0+I4Wmaw58YknBNYf0rkSBOlbNPQKnJZ SXDONxBn2MnRMiyAcm6x56dl+NrEKlioY0X/NdogX6+pFsvT6Q7JkCIDiYaNv8rlZn pOinaR69fud9w== Message-ID: Date: Mon, 7 Nov 2022 10:56:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Coverity: gpmc_is_valid_waitpin(): Control flow issues Content-Language: en-US From: Roger Quadros To: coverity-bot , Benedikt Niedermayr Cc: Krzysztof Kozlowski , linux-kernel@vger.kernel.org, Tony Lindgren , linux-omap@vger.kernel.org, "Gustavo A. R. Silva" , linux-next@vger.kernel.org, linux-hardening@vger.kernel.org References: <202211041233.4D45359E7@keescook> <7cdf3d14-3f1b-7cd4-e8b9-e94b5359bf82@kernel.org> In-Reply-To: <7cdf3d14-3f1b-7cd4-e8b9-e94b5359bf82@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/11/2022 10:53, Roger Quadros wrote: > Hi Benedikt, > > On 04/11/2022 21:33, coverity-bot wrote: >> Hello! >> >> This is an experimental semi-automated report about issues detected by >> Coverity from a scan of next-20221104 as part of the linux-next scan project: >> https://scan.coverity.com/projects/linux-next-weekly-scan >> >> You're getting this email because you were associated with the identified >> lines of code (noted below) that were touched by commits: >> >> Wed Nov 2 10:02:39 2022 -0400 >> 89aed3cd5cb9 ("memory: omap-gpmc: wait pin additions") >> >> Coverity reported the following: >> >> *** CID 1527139: Control flow issues (NO_EFFECT) >> drivers/memory/omap-gpmc.c:1048 in gpmc_is_valid_waitpin() >> 1042 spin_unlock(&gpmc_mem_lock); >> 1043 } >> 1044 EXPORT_SYMBOL(gpmc_cs_free); >> 1045 >> 1046 static bool gpmc_is_valid_waitpin(u32 waitpin) > > We will need to change this waitpin argument to int. > In addition we will also need to change > struct gpmc_waitpin->pin and struct gpmc_setting->wait_pin > to int as in the code we are relying on GPMC_WAITPIN_INVALID logic which is -1. Another alternative with less churn is to leave them as u32 but make GPMC_WAITPIN_INVALID set to a large positive number. > >> 1047 { >> vvv CID 1527139: Control flow issues (NO_EFFECT) >> vvv This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "waitpin >= 0U". >> 1048 return waitpin >= 0 && waitpin < gpmc_nr_waitpins; >> 1049 } >> 1050 >> 1051 static int gpmc_alloc_waitpin(struct gpmc_device *gpmc, >> 1052 struct gpmc_settings *p) >> 1053 { >> >> If this is a false positive, please let us know so we can mark it as >> such, or teach the Coverity rules to be smarter. If not, please make >> sure fixes get into linux-next. :) For patches fixing this, please >> include these lines (but double-check the "Fixes" first): >> >> Reported-by: coverity-bot >> Addresses-Coverity-ID: 1527139 ("Control flow issues") >> Fixes: 89aed3cd5cb9 ("memory: omap-gpmc: wait pin additions") >> >> Thanks for your attention! >> > cheers, -roger