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-next>] [day] [month] [year] [list]
Message-Id: <20241209-fix-charge-current-limit-v1-1-760d9b8f2af3@liebherr.com>
Date: Mon, 09 Dec 2024 11:46:15 +0100
From: Dimitri Fedrau via B4 Relay <devnull+dimitri.fedrau.liebherr.com@...nel.org>
To: Sebastian Reichel <sre@...nel.org>, 
 Linus Walleij <linus.walleij@...aro.org>
Cc: Sebastian Reichel <sebastian.reichel@...labora.com>, 
 linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Dimitri Fedrau <dima.fedrau@...il.com>, 
 Dimitri Fedrau <dimitri.fedrau@...bherr.com>
Subject: [PATCH] power: supply: gpio-charger: Fix set charge current limits

From: Dimitri Fedrau <dimitri.fedrau@...bherr.com>

Fix set charge current limits for devices which allow to set the lowest
charge current limit to be greater zero. If requested charge current limit
is below lowest limit, the index equals current_limit_map_size which leads
to accessing memory beyond allocated memory.

Fixes: be2919d8355e ("power: supply: gpio-charger: add charge-current-limit feature")
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@...bherr.com>
---
 drivers/power/supply/gpio-charger.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c
index 68212b39785beabfe5536a18fa15bc249f7b1eea..6139f736ecbe4ffc74848797a72095f4cadf3b62 100644
--- a/drivers/power/supply/gpio-charger.c
+++ b/drivers/power/supply/gpio-charger.c
@@ -67,6 +67,14 @@ static int set_charge_current_limit(struct gpio_charger *gpio_charger, int val)
 		if (gpio_charger->current_limit_map[i].limit_ua <= val)
 			break;
 	}
+
+	/*
+	 * If a valid charge current limit isn't found, default to smallest
+	 * current limitation for safety reasons.
+	 */
+	if (i >= gpio_charger->current_limit_map_size)
+		i = gpio_charger->current_limit_map_size - 1;
+
 	mapping = gpio_charger->current_limit_map[i];
 
 	for (i = 0; i < ndescs; i++) {

---
base-commit: 88e4a7dc04b7828315292eb3acaa466c9c123d8b
change-id: 20241209-fix-charge-current-limit-a5e5bbafdf11

Best regards,
-- 
Dimitri Fedrau <dimitri.fedrau@...bherr.com>



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ