Skip to content

Commit f10b439

Browse files
committed
Merge tag 'regulator-fix-v6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "This is more changes than I'd like this late although the diffstat is still fairly small, I kept on holding off as new fixes came in to give things time to soak in -next but should probably have tagged and sent an additional pull request earlier. There's some relatively large fixes to the twl6030 driver to fix issues with the TWL6032 variant which resulted from some work on the core TWL6030 driver, a couple of fixes for error handling paths (mostly in the core), and a nice stability fix for the sgl51000 driver that's been pulled out of a BSP" * tag 'regulator-fix-v6.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: twl6030: fix get status of twl6032 regulators regulator: twl6030: re-add TWL6032_SUBCLASS regulator: slg51000: Wait after asserting CS pin regulator: core: fix UAF in destroy_regulator() regulator: rt5759: fix OOB in validate_desc() regulator: core: fix kobject release warning and memory leak in regulator_register()
2 parents 3eaea0d + 31a6297 commit f10b439

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

drivers/regulator/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5154,6 +5154,7 @@ static void regulator_dev_release(struct device *dev)
51545154
{
51555155
struct regulator_dev *rdev = dev_get_drvdata(dev);
51565156

5157+
debugfs_remove_recursive(rdev->debugfs);
51575158
kfree(rdev->constraints);
51585159
of_node_put(rdev->dev.of_node);
51595160
kfree(rdev);
@@ -5644,11 +5645,15 @@ regulator_register(const struct regulator_desc *regulator_desc,
56445645
mutex_lock(&regulator_list_mutex);
56455646
regulator_ena_gpio_free(rdev);
56465647
mutex_unlock(&regulator_list_mutex);
5648+
put_device(&rdev->dev);
5649+
rdev = NULL;
56475650
clean:
56485651
if (dangling_of_gpiod)
56495652
gpiod_put(config->ena_gpiod);
5653+
if (rdev && rdev->dev.of_node)
5654+
of_node_put(rdev->dev.of_node);
5655+
kfree(rdev);
56505656
kfree(config);
5651-
put_device(&rdev->dev);
56525657
rinse:
56535658
if (dangling_cfg_gpiod)
56545659
gpiod_put(cfg->ena_gpiod);
@@ -5677,7 +5682,6 @@ void regulator_unregister(struct regulator_dev *rdev)
56775682

56785683
mutex_lock(&regulator_list_mutex);
56795684

5680-
debugfs_remove_recursive(rdev->debugfs);
56815685
WARN_ON(rdev->open_count);
56825686
regulator_remove_coupling(rdev);
56835687
unset_regulator_supplies(rdev);

drivers/regulator/rt5759-regulator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ static int rt5759_regulator_register(struct rt5759_priv *priv)
243243
if (priv->chip_type == CHIP_TYPE_RT5759A)
244244
reg_desc->uV_step = RT5759A_STEP_UV;
245245

246+
memset(&reg_cfg, 0, sizeof(reg_cfg));
246247
reg_cfg.dev = priv->dev;
247248
reg_cfg.of_node = np;
248249
reg_cfg.init_data = of_get_regulator_init_data(priv->dev, np, reg_desc);

drivers/regulator/slg51000-regulator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ static int slg51000_i2c_probe(struct i2c_client *client)
457457
chip->cs_gpiod = cs_gpiod;
458458
}
459459

460+
usleep_range(10000, 11000);
461+
460462
i2c_set_clientdata(client, chip);
461463
chip->chip_irq = client->irq;
462464
chip->dev = dev;

drivers/regulator/twl6030-regulator.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct twlreg_info {
6767
#define TWL6030_CFG_STATE_SLEEP 0x03
6868
#define TWL6030_CFG_STATE_GRP_SHIFT 5
6969
#define TWL6030_CFG_STATE_APP_SHIFT 2
70+
#define TWL6030_CFG_STATE_MASK 0x03
7071
#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
7172
#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
7273
TWL6030_CFG_STATE_APP_SHIFT)
@@ -128,13 +129,14 @@ static int twl6030reg_is_enabled(struct regulator_dev *rdev)
128129
if (grp < 0)
129130
return grp;
130131
grp &= P1_GRP_6030;
132+
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
133+
val = TWL6030_CFG_STATE_APP(val);
131134
} else {
135+
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
136+
val &= TWL6030_CFG_STATE_MASK;
132137
grp = 1;
133138
}
134139

135-
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
136-
val = TWL6030_CFG_STATE_APP(val);
137-
138140
return grp && (val == TWL6030_CFG_STATE_ON);
139141
}
140142

@@ -187,7 +189,12 @@ static int twl6030reg_get_status(struct regulator_dev *rdev)
187189

188190
val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
189191

190-
switch (TWL6030_CFG_STATE_APP(val)) {
192+
if (info->features & TWL6032_SUBCLASS)
193+
val &= TWL6030_CFG_STATE_MASK;
194+
else
195+
val = TWL6030_CFG_STATE_APP(val);
196+
197+
switch (val) {
191198
case TWL6030_CFG_STATE_ON:
192199
return REGULATOR_STATUS_NORMAL;
193200

@@ -530,6 +537,7 @@ static const struct twlreg_info TWL6030_INFO_##label = { \
530537
#define TWL6032_ADJUSTABLE_LDO(label, offset) \
531538
static const struct twlreg_info TWL6032_INFO_##label = { \
532539
.base = offset, \
540+
.features = TWL6032_SUBCLASS, \
533541
.desc = { \
534542
.name = #label, \
535543
.id = TWL6032_REG_##label, \
@@ -562,6 +570,7 @@ static const struct twlreg_info TWLFIXED_INFO_##label = { \
562570
#define TWL6032_ADJUSTABLE_SMPS(label, offset) \
563571
static const struct twlreg_info TWLSMPS_INFO_##label = { \
564572
.base = offset, \
573+
.features = TWL6032_SUBCLASS, \
565574
.desc = { \
566575
.name = #label, \
567576
.id = TWL6032_REG_##label, \

0 commit comments

Comments
 (0)