lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48a348a0-0489-45bb-874b-246c7683a5a5@t-8ch.de>
Date: Thu, 4 Jul 2024 20:16:18 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Benson Leung <bleung@...omium.org>, 
	Guenter Roeck <groeck@...omium.org>, Sebastian Reichel <sre@...nel.org>, 
	Tzung-Bi Shih <tzungbi@...nel.org>, chrome-platform@...ts.linux.dev, linux-pm@...r.kernel.org, 
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] power: supply: cros_charge-control: Fix signedness bug
 in charge_behaviour_store()

Hi Dan,

Thanks!

On 2024-07-04 10:20:03+0000, Dan Carpenter wrote:
> The C standard is vague about the signedness of enums, but in this case
> here, they are treated as unsigned so the error handling does not work.
> Use an int type to fix this.
> 
> Fixes: c6ed48ef5259 ("power: supply: add ChromeOS EC based charge control driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>

Acked-by: Thomas Weißschuh <linux@...ssschuh.net>

> ---
>  drivers/power/supply/cros_charge-control.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
> index 73d7f2dc0fa3..3183a13eefd0 100644
> --- a/drivers/power/supply/cros_charge-control.c
> +++ b/drivers/power/supply/cros_charge-control.c
> @@ -204,14 +204,13 @@ static ssize_t charge_behaviour_store(struct device *dev, struct device_attribut
>  {
>  	struct cros_chctl_priv *priv = cros_chctl_attr_to_priv(&attr->attr,
>  							       CROS_CHCTL_ATTR_CHARGE_BEHAVIOUR);
> -	enum power_supply_charge_behaviour behaviour;
>  	int ret;
>  
> -	behaviour = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
> -	if (behaviour < 0)
> -		return behaviour;
> +	ret = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
> +	if (ret < 0)
> +		return ret;
>  
> -	priv->current_behaviour = behaviour;
> +	priv->current_behaviour = ret;
>  
>  	ret = cros_chctl_configure_ec(priv);
>  	if (ret < 0)
> -- 
> 2.43.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ