[PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap
From: Axel Lin
Date: Wed May 19 2021 - 03:50:52 EST
Return -EINVAL if ramp_delay_table is NULL.
Also add WARN_ON since the driver code needs fix if this happened.
Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
---
drivers/regulator/helpers.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 0e16e31c968f..1e61fec4636e 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -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);
--
2.25.1