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] [day] [month] [year] [list]
Message-ID: <CAJZ5v0hi_Sa6KW=kOto0Hm5-D85=8z30Oobhtt3yKNwL9VZ6nw@mail.gmail.com>
Date: Mon, 3 Nov 2025 17:32:44 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Alexey Starikovskiy <astarikovskiy@...e.de>, 
	Harshit Mogalapalli <harshit.m.mogalapalli@...il.com>, "Rafael J. Wysocki" <rafael@...nel.org>, 
	Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org, 
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] ACPI: SBS: Fix present test in acpi_battery_read()

On Fri, Oct 31, 2025 at 2:03 PM Dan Carpenter <dan.carpenter@...aro.org> wrote:
>
> The battery->present variable is a 1 bit bitfield in a u8.  This means
> that the "state & (1 << battery->id)" test will only work when
> "battery->id" is zero, otherwise ->present is zero.  Fix this by adding
> a !!.
>
> Fixes: db1c291af7ad ("ACPI: SBS: Make SBS reads table-driven.")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
> This is a new static checker warning that Harshit and I wrote.  It's
> untested.
>
>  drivers/acpi/sbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index a3f95a3fffde..d3edc3bcbf01 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -487,7 +487,7 @@ static int acpi_battery_read(struct acpi_battery *battery)
>                 if (result)
>                         return result;
>
> -               battery->present = state & (1 << battery->id);
> +               battery->present = !!(state & (1 << battery->id));
>                 if (!battery->present)
>                         return 0;
>
> --

Applied as 6.18-rc material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ