Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4534421rwb; Tue, 6 Sep 2022 08:49:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LYA20iGqmnNexC36VwONvBvvkdlsj13yyYhi/PhKmCe3N+Kw+G78f5cdwgtPcvkpCaP5P X-Received: by 2002:a17:90b:3a8e:b0:200:5585:4099 with SMTP id om14-20020a17090b3a8e00b0020055854099mr13175639pjb.70.1662479390039; Tue, 06 Sep 2022 08:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662479390; cv=none; d=google.com; s=arc-20160816; b=KqH0x3YoxOWjsIQHrkkNt/+rUAQ+QPI3LvntHjq9D/ezUP9NQfJM/WXZh4idrlzMdt aIYddll3TFcJVDOJ/ysOtPvbQKkvLNiBgHJPEzTls+r8OxCjg2UynzDX6iWHblJ87LUB Y2rR8/Qcw2jyojSY9Yb7Y8l9JMLOvPCXTNRMklyiSRFQQzhP1A/Jh0eKihtJFwZa/zdR rTo+Ne77kWLnho1mhkS6w62DlVYucLiiUUMraXTG9HVN4i4zKG39AFAmRFnDCWwE5BVX tPer9prixQpN6GFsLzAXK4065SlS7HLuiSrZ56gO+WNrFXwoIARQvEOkZg+6ooO5Q3qM HQPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=oSvf8BKjL+AVksdSWpXS54JbRkauU+S4Q3sElY0qhGw=; b=amp4ej1u4a+6vJbq4o9Y+fg0aLU2bjSjyy3h8HDiTExFY03lNNOMwpp26s6xbgFAvN R+hma189HNEKan2kPoQY66dUTwj9nNrNfBy8JpdqvBCFO3kX+Ctr0Vqlz1TPAq3UD17J EGZY34PnGErue0QFprebrnbkdjJTKO0li5/nzyG0wiARvTNFJnzyt8GubvPuAjULjb5U ArYBRQSO+tjpogilUCZRVX0gQyHhPArIwo2vaM7GekSWkh3nQCAA/za0d2jKmJ9a0mzv N3DoQn5Or0GDbMISwphuOHokhUjbRnU/owzp/i+dLauXtsfrLLncQGP4YOsi4cefZxo/ 1jdw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd32-20020a056a0027a000b0052f44beb0d1si11560582pfb.291.2022.09.06.08.49.38; Tue, 06 Sep 2022 08:49:50 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232276AbiIFPmC (ORCPT + 99 others); Tue, 6 Sep 2022 11:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239140AbiIFPiv (ORCPT ); Tue, 6 Sep 2022 11:38:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B9F06C7432; Tue, 6 Sep 2022 07:48:53 -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 29BCC1AC1; Tue, 6 Sep 2022 07:24:37 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A6E023F7B4; Tue, 6 Sep 2022 07:24:28 -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, lukasz.luba@arm.com Subject: [PATCH v2 2/3] powercap: arm_scmi: Fix signedness bug in probe Date: Tue, 6 Sep 2022 15:23:36 +0100 Message-Id: <20220906142337.1697569-3-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220906142337.1697569-1-cristian.marussi@arm.com> References: <20220906142337.1697569-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 From: Dan Carpenter The "pr->num_zones" variable is an unsigned int so it can't be less than zero. 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 a91438867f8c..76200c004cad 100644 --- a/drivers/powercap/arm_scmi_powercap.c +++ b/drivers/powercap/arm_scmi_powercap.c @@ -389,11 +389,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); -- 2.32.0