ImmortalWrt/target/linux/at91/patches-5.10/127-regulator-core-validate-selector-against-linear_min_.patch
John Audia 2835df54ab kernel: bump 5.10 to 5.10.163
Removed upstreamed:
  generic/101-Use-stddefs.h-instead-of-compiler.h.patch[1]

All patches automatically rebased.

1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.10.163&id=ddd2bb08bd99b7ee4442fbbe0f9b80236fdd71d2

Build system: x86_64
Build-tested: ramips/tplink_archer-a6-v3
Run-tested: ramips/tplink_archer-a6-v3

Signed-off-by: John Audia <therealgraysky@proton.me>
2023-01-14 22:31:38 +01:00

65 lines
2.3 KiB
Diff

From 3aee4f22ed0a22d3d6d22fc49812c03d876c7637 Mon Sep 17 00:00:00 2001
From: Claudiu Beznea <claudiu.beznea@microchip.com>
Date: Fri, 13 Nov 2020 17:21:05 +0200
Subject: [PATCH 127/247] regulator: core: validate selector against
linear_min_sel
There are regulators who's min selector is not zero. Selectors loops
(looping b/w zero and regulator::desc::n_voltages) might throw errors
because invalid selectors are used (lower than
regulator::desc::linear_min_sel). For this situations validate selectors
against regulator::desc::linear_min_sel.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/1605280870-32432-2-git-send-email-claudiu.beznea@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/regulator/core.c | 9 +++++++--
drivers/regulator/helpers.c | 3 ++-
2 files changed, 9 insertions(+), 3 deletions(-)
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3000,7 +3000,8 @@ static int _regulator_list_voltage(struc
return rdev->desc->fixed_uV;
if (ops->list_voltage) {
- if (selector >= rdev->desc->n_voltages)
+ if (selector >= rdev->desc->n_voltages ||
+ selector < rdev->desc->linear_min_sel)
return -EINVAL;
if (lock)
regulator_lock(rdev);
@@ -3151,7 +3152,8 @@ int regulator_list_hardware_vsel(struct
struct regulator_dev *rdev = regulator->rdev;
const struct regulator_ops *ops = rdev->desc->ops;
- if (selector >= rdev->desc->n_voltages)
+ if (selector >= rdev->desc->n_voltages ||
+ selector < rdev->desc->linear_min_sel)
return -EINVAL;
if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap)
return -EOPNOTSUPP;
@@ -4074,6 +4076,9 @@ int regulator_set_voltage_time(struct re
for (i = 0; i < rdev->desc->n_voltages; i++) {
/* We only look for exact voltage matches here */
+ if (i < rdev->desc->linear_min_sel)
+ continue;
+
voltage = regulator_list_voltage(regulator, i);
if (voltage < 0)
return -EINVAL;
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -647,7 +647,8 @@ int regulator_list_voltage_table(struct
return -EINVAL;
}
- if (selector >= rdev->desc->n_voltages)
+ if (selector >= rdev->desc->n_voltages ||
+ selector < rdev->desc->linear_min_sel)
return -EINVAL;
return rdev->desc->volt_table[selector];