Skip to contentSkip to conversation

regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap

PATCH Superseded Axel Lin 2 participants 3 messages May 19, 2021 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap

Return -EINVAL if ramp_delay_table is NULL.
Also add WARN_ON since the driver code needs fix if this happened.

---
 drivers/regulator/helpers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/helpers.c +3 -1
index 0e16e31c968f..1e61fec4636e 100644
@@ -948,8 +948,10 @@ int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay)
 	int ret;
 	unsigned int sel;
 
-	if (!rdev->desc->n_ramp_values)
+	if (!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table) {
+		WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table);
 		return -EINVAL;
+	}
 
 	ret = find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table,
 				  rdev->desc->n_ramp_values, &sel);
Signature · 1 line
2.25.1
maintainer
#1 lore raw

drivers/regulator/helpers.c int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay) · line 952

Quoted 2 lines · Axel Lin
drivers/regulator/helpers.c +2 -0
+	if (!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table) {
+		WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table);

You can write "if (WARN_ON(..." there and it'll DTRT, though I'm never sure it's great for readability.

maintainer
#2 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

Return -EINVAL if ramp_delay_table is NULL.
Also add WARN_ON since the driver code needs fix if this happened.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap

      commit: 687c9e3b1a81d43b233482f781bd4e20561bc390

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark