Dorian Rudolph
093d27bb6f
power: supply: core: Fix boundary conditions in interpolation
...
The functions power_supply_temp2resist_simple and power_supply_ocv2cap_simple
handle boundary conditions incorrectly.
The change was introduced in a4585ba205
("power: supply: core: Use library interpolation").
There are two issues: First, the lines "high = i - 1" and "high = i" in ocv2cap
have the wrong order compared to temp2resist. As a consequence, ocv2cap
sets high=-1 if ocv>table[0].ocv, which causes an out-of-bounds read.
Second, the logic of temp2resist is also not correct.
Consider the case table[] = {{20, 100}, {10, 80}, {0, 60}}.
For temp=5, we expect a resistance of 70% by interpolation.
However, temp2resist sets high=low=2 and returns 60.
Cc: stable@vger.kernel.org
Signed-off-by: Dorian Rudolph <mail@dorianrudolph.com >
Reviewed-by: Linus Walleij <linus.walleij@linaro.org >
Fixes: a4585ba205 ("power: supply: core: Use library interpolation")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com >
2022-06-09 21:08:38 +02:00
..
2021-04-02 14:14:58 +02:00
2019-06-19 17:09:55 +02:00
2022-02-28 11:34:31 +01:00
2022-02-28 11:34:31 +01:00
2022-03-14 17:24:52 +01:00
2022-03-28 12:41:28 -07:00
2022-06-09 21:08:06 +02:00
2022-02-28 11:34:31 +01:00
2021-11-22 17:16:26 +01:00
2021-01-14 23:39:43 +01:00
2021-04-20 16:18:08 +02:00
2019-05-30 11:29:19 -07:00
2022-03-04 22:20:32 +01:00
2022-02-01 11:18:47 +01:00
2022-03-04 22:20:32 +01:00
2022-05-13 17:03:40 +09:00
2022-05-03 17:01:53 +02:00
2022-01-03 18:53:10 +01:00
2020-05-10 02:35:49 +02:00
2020-10-20 10:56:34 -07:00
2021-11-02 13:47:19 +01:00
2022-05-04 23:44:03 +02:00
2022-02-11 21:19:51 +01:00
2020-07-28 02:07:35 +02:00
2022-01-03 18:53:10 +01:00
2022-05-04 23:44:03 +02:00
2020-10-03 22:17:50 +02:00
2021-08-13 18:38:17 +02:00
2022-02-01 14:55:12 +01:00
2022-02-24 12:09:20 +01:00
2020-10-04 01:54:35 +02:00
2022-05-13 17:03:40 +09:00
2020-11-30 02:18:49 +01:00
2022-02-01 12:47:11 +01:00
2021-06-04 14:36:17 +02:00
2022-02-13 22:20:12 +01:00
2022-01-31 22:42:25 +01:00
2022-02-01 13:13:44 +01:00
2020-07-27 00:05:56 +02:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2022-03-04 22:20:33 +01:00
2021-01-28 01:31:42 +01:00
2021-01-16 12:36:26 +01:00
2021-03-22 15:05:41 +01:00
2019-06-19 17:09:55 +02:00
2021-04-08 14:35:19 +02:00
2020-10-03 22:17:50 +02:00
2020-08-27 21:13:23 +02:00
2022-01-03 18:53:10 +01:00
2022-03-04 22:33:00 +01:00
2020-01-17 02:13:00 +01:00
2020-04-10 15:36:22 -07:00
2022-03-04 22:33:00 +01:00
2020-08-26 17:25:45 +02:00
2019-06-19 17:09:55 +02:00
2021-03-22 14:54:24 +01:00
2019-04-10 00:39:01 +02:00
2022-02-13 22:21:42 +01:00
2021-01-13 22:11:43 +01:00
2022-03-04 22:33:00 +01:00
2021-03-22 15:11:22 +01:00
2021-01-12 23:23:49 +01:00
2020-08-23 17:36:59 -05:00
2022-05-13 17:03:40 +09:00
2020-06-19 19:58:23 +02:00
2021-04-20 16:18:08 +02:00
2022-02-24 12:19:20 +01:00
2021-10-12 17:18:46 +02:00
2022-02-24 12:00:14 +01:00
2019-12-19 01:13:26 +01:00
2018-08-30 00:18:10 +02:00
2021-11-16 16:10:07 +01:00
2022-02-01 10:32:35 +01:00
2021-08-13 18:37:49 +02:00
2020-05-10 18:56:30 +02:00
2019-05-30 11:26:32 -07:00
2019-12-19 01:07:53 +01:00
2019-05-30 11:29:22 -07:00
2019-06-19 17:09:55 +02:00
2022-06-09 21:08:38 +02:00
2022-02-11 19:45:52 +01:00
2019-05-30 11:29:54 -07:00
2022-02-24 12:09:20 +01:00
2019-05-30 11:29:54 -07:00
2021-11-30 11:34:27 +01:00
2021-08-13 18:38:17 +02:00
2021-10-12 17:12:23 +02:00
2022-02-11 19:52:56 +01:00
2020-04-10 15:36:22 -07:00
2021-04-08 14:36:08 +02:00
2022-04-13 12:05:22 +02:00
2022-03-04 22:20:18 +01:00
2021-08-06 23:48:51 +02:00
2022-02-24 12:16:21 +01:00
2021-04-02 14:19:26 +02:00
2022-01-03 18:53:10 +01:00
2022-01-03 18:53:10 +01:00
2022-02-24 11:47:55 +01:00
2021-05-13 18:26:07 +02:00
2021-06-03 20:53:54 +02:00
2020-10-09 01:02:30 +02:00
2022-05-07 22:55:33 +02:00
2021-03-22 14:54:24 +01:00
2021-03-22 14:54:24 +01:00
2020-03-11 23:20:32 +01:00
2019-05-21 10:50:45 +02:00
2020-10-01 00:18:05 +02:00
2022-02-11 19:08:35 +01:00
2020-07-31 14:33:56 +02:00
2021-01-13 22:25:07 +01:00
2019-06-19 17:09:55 +02:00
2021-10-02 17:31:15 +02:00
2022-03-04 22:20:32 +01:00
2021-03-15 00:08:07 +01:00