From patchwork Wed Aug 17 10:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 598392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75512C32772 for ; Wed, 17 Aug 2022 10:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238854AbiHQKyt (ORCPT ); Wed, 17 Aug 2022 06:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238810AbiHQKys (ORCPT ); Wed, 17 Aug 2022 06:54:48 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4CD111572E; Wed, 17 Aug 2022 03:54:47 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D7E4A1570; Wed, 17 Aug 2022 03:54:47 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 147AE3F67D; Wed, 17 Aug 2022 03:54:44 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, Jonathan.Cameron@Huawei.com, f.fainelli@gmail.com, etienne.carriere@linaro.org, vincent.guittot@linaro.org, daniel.lezcano@linaro.org, tarek.el-sherbiny@arm.com, adrian.slatineanu@arm.com, souvik.chakravarty@arm.com, wleavitt@marvell.com, wbartczak@marvell.com, dan.carpenter@oracle.com Subject: [PATCH 2/3] powercap: arm_scmi: Fix signedness bug in probe Date: Wed, 17 Aug 2022 11:54:23 +0100 Message-Id: <20220817105424.3124006-3-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817105424.3124006-1-cristian.marussi@arm.com> References: <20220817105424.3124006-1-cristian.marussi@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Dan Carpenter The "pr->num_zones" variable is an unsigned int so it can't be less than zero. Fixes: 31afdd34f2b9 ("powercap: arm_scmi: Add SCMI powercap based driver") Signed-off-by: Dan Carpenter --- drivers/powercap/arm_scmi_powercap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/powercap/arm_scmi_powercap.c b/drivers/powercap/arm_scmi_powercap.c index 9f3b8386b4d8..dc26cbb32b35 100644 --- a/drivers/powercap/arm_scmi_powercap.c +++ b/drivers/powercap/arm_scmi_powercap.c @@ -425,11 +425,12 @@ static int scmi_powercap_probe(struct scmi_device *sdev) if (!pr) return -ENOMEM; - pr->num_zones = powercap_ops->num_domains_get(ph); - if (pr->num_zones < 0) { + ret = powercap_ops->num_domains_get(ph); + if (ret < 0) { dev_err(dev, "number of powercap domains not found\n"); - return pr->num_zones; + return ret; } + pr->num_zones = ret; pr->spzones = devm_kcalloc(dev, pr->num_zones, sizeof(*pr->spzones), GFP_KERNEL);