From patchwork Tue Sep 29 17:08:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 11806375 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 CE426618 for ; Tue, 29 Sep 2020 17:04:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80544208B8 for ; Tue, 29 Sep 2020 17:04:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BvY5q/lF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="JY3aizJ4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80544208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=XKRO1/u9USFX8xoCNoKbAinXLmNx97DpjyXfyOPA178=; b=BvY5q/lFLSBY/0rQceabK9UK1q /wyXDkDOLJc+PzfwhxWbs709QYZDrcUFLxBNYlQL52zHEuCBut657iLbvpglNovZcyQxVt8OD1Ybc Ia8TIuNbWfsP6iaPbN5qqqGJIRM/Qt3+RhAJZctB6gIeA6RKFNwNNI6ikZ83EdPDroX+rdPdeyccR dlmaY6nNqZfTgsprr3H7tkUM1CbL9GbtBMzI0BZR0iItq8Fvq4Wu7tltnYMcN8LfcTCehCL9FPxRW 4a2Uj7jg8eMAy/y7YDkFUnS4j5EUiVT5e5xNMSDy/qX7pc26VJCyIkiGV83zCPRCbv8nAKtiS1vpE 9jcckByA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNJ1m-0007ZY-MP; Tue, 29 Sep 2020 17:02:58 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNJ1j-0007Yv-NU for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2020 17:02:56 +0000 Received: from embeddedor (187-162-31-110.static.axtel.net [187.162.31.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 90CE8208B8; Tue, 29 Sep 2020 17:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601398974; bh=6sxhzxES43pi5ZwcvSOYXKElL659FR/ANkscAcTnenk=; h=Date:From:To:Cc:Subject:From; b=JY3aizJ4AVhdJISbRasOcjhkl0CUKga5HepsCPOpYl9A+Q+NLp+GukB0pW7hS1OnY F3+59//DDyK5akylc/L9ZCSZiy4syj7G5YYTC+CcsNRbgxewISYpMkI+ILzBWCBPen 2lofEMRESoC4s+HJ5dgLx+sVTteLXS1v9SOEoO9k= Date: Tue, 29 Sep 2020 12:08:35 -0500 From: "Gustavo A. R. Silva" To: Will Deacon , Mark Rutland , Robin Murphy Subject: [PATCH][next] perf: arm-cmn: Fix unsigned comparison to less than zero Message-ID: <20200929170835.GA15956@embeddedor> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200929_130255_846161_B4966060 X-CRM114-Status: GOOD ( 14.56 ) X-Spam-Score: -5.9 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.7 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robin Murphy , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Gustavo A. R. Silva" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Fix unsigned comparison to less than zero by assigning the returned value of function platform_get_irq() to a new integer variable _ret_ and then make the comparison. In case the returned value is greater than or equal to zero, assign it to dtc->irq. Addresses-Coverity-ID: 1497488 ("Unsigned compared against 0") Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver") Signed-off-by: Gustavo A. R. Silva --- drivers/perf/arm-cmn.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index e824b5b83ea2..383b67042677 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1246,11 +1246,13 @@ static int arm_cmn_init_dtc(struct arm_cmn *cmn, struct arm_cmn_node *dn, int id { struct arm_cmn_dtc *dtc = cmn->dtc + idx; struct arm_cmn_node *xp; + int ret; dtc->base = dn->pmu_base - CMN_PMU_OFFSET; - dtc->irq = platform_get_irq(to_platform_device(cmn->dev), idx); - if (dtc->irq < 0) - return dtc->irq; + ret = platform_get_irq(to_platform_device(cmn->dev), idx); + if (ret < 0) + return ret; + dtc->irq = ret; writel_relaxed(0, dtc->base + CMN_DT_PMCR); writel_relaxed(0x1ff, dtc->base + CMN_DT_PMOVSR_CLR);