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: <20131113135051.GA13304@jak-x230>
Date:	Wed, 13 Nov 2013 14:50:51 +0100
From:	Julian Andres Klode <jak@...-linux.org>
To:	Julian Andres Klode <jak@...-linux.org>
Cc:	Henrique de Moraes Holschuh <ibm-acpi@....eng.br>,
	Matthew Garrett <matthew.garrett@...ula.com>,
	"open list:THINKPAD ACPI EXT..." 
	<ibm-acpi-devel@...ts.sourceforge.net>,
	"open list:THINKPAD ACPI EXT..." 
	<platform-driver-x86@...r.kernel.org>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/4] thinkpad_acpi: Add support for controlling charge
 thresholds

On Mon, Nov 11, 2013 at 02:56:30PM +0100, Julian Andres Klode wrote:
> +static int __init battery_init(struct ibm_init_struct *iibm)

> +	for (i = 0; i < BATTERY_MAX_COUNT; i++) {
> +		int j = 0;
> +		if (!acpi_evalf(hkey_handle, &state, "BCTG", "qdd", i + 1))
> +			continue;
> +		/* If the sign bit was set, we could not get the start charge
> +		 * threshold of that battery. Let's assume that this battery
> +		 * (and all following ones) do not exist */
> +		if (state < 0)
> +			break;
> +		/* Modify BATTERY_MAX_ATTRS if you add an attribute */
> +		batteries[i].attributes[j++] = (struct dev_ext_attribute) {
> +			.attr = __ATTR(start_charge_tresh,
> +				       S_IWUSR | S_IRUGO,
> +				       battery_start_charge_thresh_show,
> +				       battery_start_charge_thresh_store),
> +			.var = (void *) (unsigned long) (i + 1)
> +		};
> +		batteries[i].attributes[j++] = (struct dev_ext_attribute) {
> +			.attr = __ATTR(stop_charge_tresh,
> +				       S_IWUSR | S_IRUGO,
> +				       battery_stop_charge_thresh_show,
> +				       battery_stop_charge_thresh_store),
> +			.var = (void *) (unsigned long) (i + 1)
> +		};
> +
> +		strncpy(batteries[i].name, "BAT", 3);
> +		batteries[i].name[3] = '0' + i;
> +		batteries[i].name[4] = '\0';
> +		batteries[i].set = create_attr_set(j - 1, batteries[i].name);
> +

There's a bug here that I just noticed: It should be (j) attributes, not (j - 1)
ones. The following patch fixes this. I can squash it into that patch and resubmit
later on if requested.

-- >8 --
Subject: [PATCH] thinkpad_acpi: battery: Fix the size of the battery attribute sets

There are not j - 1, but j attributes.

Signed-off-by: Julian Andres Klode <jak@...-linux.org>
---
 drivers/platform/x86/thinkpad_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index a9cba4e..6948141 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8613,7 +8613,7 @@ static int __init battery_init(struct ibm_init_struct *iibm)
 		strncpy(batteries[i].name, "BAT", 3);
 		batteries[i].name[3] = '0' + i;
 		batteries[i].name[4] = '\0';
-		batteries[i].set = create_attr_set(j - 1, batteries[i].name);
+		batteries[i].set = create_attr_set(j, batteries[i].name);
 
 		for (j = j - 1; j >= 0; j--)
 			add_to_attr_set(batteries[i].set,
-- 
1.8.4.2


-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.

Please do not top-post if possible.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ