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: 12945709 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38192C25B08 for ; Wed, 17 Aug 2022 10:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9dKwIntEea9KZat1XdgniQu7mWmFLuDoNFPpm1e1+VQ=; b=eHfuKvXMSvUYZc RhppDbwUpyoJf2JxmxGjuB4wkL74X3/3uQ91k7eKqiju75UkTTqi/oe7xoTomAtG89a/Lq/LURXz3 TNW4I0fx7l2FqYPcJRow8tdY3HZ16K8zRVs2w1b9pUphZpWqeDJ+MEKL9BkeFPRyHNrkUjziLcyPw WaflV5gXbIsgYITTwj9239UjoBQ+tUtcE7RwO8DU0+cDIsHFZMIVQV5En1qAt5UvuxOYHAMGUe0OB 7crlDLdRYrb9vaXNR9HQzhf/7osu90J1GWhjdVAEtbk0heh8znERdxAK5jKOmzb6ed4azkxyPcHY3 nA5E56KlWYWxoWzzo/BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOGhd-000vTF-UR; Wed, 17 Aug 2022 10:55:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOGhF-000v8g-Cm for linux-arm-kernel@lists.infradead.org; Wed, 17 Aug 2022 10:54:51 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220817_035449_507686_93C85452 X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);