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: <4448104.DkuDPgeVpq@aspire.rjw.lan>
Date:   Thu, 19 Jul 2018 12:55:21 +0200
From:   "Rafael J. Wysocki" <rjw@...ysocki.net>
To:     Lucas Magasweran <lucas.magasweran@...e.org>
Cc:     linux-acpi@...r.kernel.org,
        Alexey Starikovskiy <astarikovskiy@...e.de>,
        Len Brown <lenb@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ACPI: battery: remove redundant old_present check on insertion

On Sunday, July 15, 2018 12:40:18 AM CEST Lucas Magasweran wrote:
> From: Lucas Rangit Magasweran <lucas.magasweran@...e.org>
> 
> On removal battery_present changes from 1 to 0 after calling
> acpi_battery_get_statu() and battery->update_time is set to 0
> before returning.
> 
> On insertion battery_present changes from 0 to 1 after calling
> acpi_battery_get_status() and acpi_battery_get_info() is called
> because battery->update_time is 0.
> 
> The old_present condition is therefore redundant.
> 
> This was added in the commit below when there was a path without
> sysfs that would skip getting the newly inserted battery info.
> 
> commit 50b178512b7d ("Newly inserted battery might differ from one
> just removed, so update of battery info fields is required.")
> 
> Signed-off-by: Lucas Rangit Magasweran <lucas.magasweran@...e.org>
> ---
>  drivers/acpi/battery.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index f88bc9f..c280e8e 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -918,10 +918,11 @@ static void acpi_battery_quirks(struct acpi_battery *battery)
>  
>  static int acpi_battery_update(struct acpi_battery *battery, bool resume)
>  {
> -	int result, old_present = acpi_battery_present(battery);
> -	result = acpi_battery_get_status(battery);
> +	int result = acpi_battery_get_status(battery);
> +
>  	if (result)
>  		return result;
> +
>  	if (!acpi_battery_present(battery)) {
>  		sysfs_remove_battery(battery);
>  		battery->update_time = 0;
> @@ -931,8 +932,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume)
>  	if (resume)
>  		return 0;
>  
> -	if (!battery->update_time ||
> -	    old_present != acpi_battery_present(battery)) {
> +	if (!battery->update_time) {
>  		result = acpi_battery_get_info(battery);
>  		if (result)
>  			return result;
> 

Applied, thanks!


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ