diff mbox series

[1/2] powercap: arm_scmi: Fix signedness bug in probe

Message ID YsWbsKolf4UFeEYz@kili (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series [1/2] powercap: arm_scmi: Fix signedness bug in probe | expand

Commit Message

Dan Carpenter July 6, 2022, 2:26 p.m. UTC
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 <dan.carpenter@oracle.com>
---
 drivers/powercap/arm_scmi_powercap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Cristian Marussi July 6, 2022, 2:52 p.m. UTC | #1
On Wed, Jul 06, 2022 at 05:26:56PM +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>

Hi,

Thanks for having a look.

This driver has NOT been pulled in this cycle due to a lack of
reviews/feedbacks so I'll integrate your fixes in the next version.

Thanks,
Cristian

> ---
>  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 2273768d70ce..ab96cf9a8604 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);
> -- 
> 2.35.1
>
diff mbox series

Patch

diff --git a/drivers/powercap/arm_scmi_powercap.c b/drivers/powercap/arm_scmi_powercap.c
index 2273768d70ce..ab96cf9a8604 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);