Skip to content

Commit 4b02ed4

Browse files
committed
Merge tag 'regulator-fix-v6.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "A few driver fixes (the GPIO one being potentially nasty, though it has been there for a while without anyone reporting it), and one core fix for the rarely used combination of coupled regulators and unbinding" * tag 'regulator-fix-v6.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods regulator: mp886x: Fix ID table driver_data regulator: sy8824x: Fix ID table driver_data regulator: tps65219: Fix devm_kmalloc size allocation regulator: core: fix NULL dereference on unbind due to stale coupling data
2 parents a1d8128 + c9764fd commit 4b02ed4

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5639,6 +5639,7 @@ static void regulator_remove_coupling(struct regulator_dev *rdev)
56395639
ERR_PTR(err));
56405640
}
56415641

5642+
rdev->coupling_desc.n_coupled = 0;
56425643
kfree(rdev->coupling_desc.coupled_rdevs);
56435644
rdev->coupling_desc.coupled_rdevs = NULL;
56445645
}

drivers/regulator/gpio-regulator.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,10 @@ static int gpio_regulator_probe(struct platform_device *pdev)
260260
return -ENOMEM;
261261
}
262262

263-
drvdata->gpiods = devm_kzalloc(dev, sizeof(struct gpio_desc *),
264-
GFP_KERNEL);
263+
drvdata->gpiods = devm_kcalloc(dev, config->ngpios,
264+
sizeof(struct gpio_desc *), GFP_KERNEL);
265+
if (!drvdata->gpiods)
266+
return -ENOMEM;
265267

266268
if (config->input_supply) {
267269
drvdata->desc.supply_name = devm_kstrdup(&pdev->dev,
@@ -274,8 +276,6 @@ static int gpio_regulator_probe(struct platform_device *pdev)
274276
}
275277
}
276278

277-
if (!drvdata->gpiods)
278-
return -ENOMEM;
279279
for (i = 0; i < config->ngpios; i++) {
280280
drvdata->gpiods[i] = devm_gpiod_get_index(dev,
281281
NULL,

drivers/regulator/mp886x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ static const struct of_device_id mp886x_dt_ids[] = {
348348
MODULE_DEVICE_TABLE(of, mp886x_dt_ids);
349349

350350
static const struct i2c_device_id mp886x_id[] = {
351-
{ "mp886x", (kernel_ulong_t)&mp8869_ci },
351+
{ "mp8867", (kernel_ulong_t)&mp8867_ci },
352+
{ "mp8869", (kernel_ulong_t)&mp8869_ci },
352353
{ },
353354
};
354355
MODULE_DEVICE_TABLE(i2c, mp886x_id);

drivers/regulator/sy8824x.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ static const struct of_device_id sy8824_dt_ids[] = {
213213
MODULE_DEVICE_TABLE(of, sy8824_dt_ids);
214214

215215
static const struct i2c_device_id sy8824_id[] = {
216-
{ "sy8824", (kernel_ulong_t)&sy8824c_cfg },
216+
{ "sy8824c", (kernel_ulong_t)&sy8824c_cfg },
217+
{ "sy8824e", (kernel_ulong_t)&sy8824e_cfg },
218+
{ "sy20276", (kernel_ulong_t)&sy20276_cfg },
219+
{ "sy20278", (kernel_ulong_t)&sy20278_cfg },
217220
{ }
218221
};
219222
MODULE_DEVICE_TABLE(i2c, sy8824_id);

drivers/regulator/tps65219-regulator.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -436,46 +436,46 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
436436
pmic->rdesc[i].name);
437437
}
438438

439-
irq_data = devm_kmalloc(tps->dev, pmic->common_irq_size, GFP_KERNEL);
440-
if (!irq_data)
441-
return -ENOMEM;
442-
443439
for (i = 0; i < pmic->common_irq_size; ++i) {
444440
irq_type = &pmic->common_irq_types[i];
445441
irq = platform_get_irq_byname(pdev, irq_type->irq_name);
446442
if (irq < 0)
447443
return -EINVAL;
448444

449-
irq_data[i].dev = tps->dev;
450-
irq_data[i].type = irq_type;
445+
irq_data = devm_kmalloc(tps->dev, sizeof(*irq_data), GFP_KERNEL);
446+
if (!irq_data)
447+
return -ENOMEM;
448+
449+
irq_data->dev = tps->dev;
450+
irq_data->type = irq_type;
451451
error = devm_request_threaded_irq(tps->dev, irq, NULL,
452452
tps65219_regulator_irq_handler,
453453
IRQF_ONESHOT,
454454
irq_type->irq_name,
455-
&irq_data[i]);
455+
irq_data);
456456
if (error)
457457
return dev_err_probe(tps->dev, PTR_ERR(rdev),
458458
"Failed to request %s IRQ %d: %d\n",
459459
irq_type->irq_name, irq, error);
460460
}
461461

462-
irq_data = devm_kmalloc(tps->dev, pmic->dev_irq_size, GFP_KERNEL);
463-
if (!irq_data)
464-
return -ENOMEM;
465-
466462
for (i = 0; i < pmic->dev_irq_size; ++i) {
467463
irq_type = &pmic->irq_types[i];
468464
irq = platform_get_irq_byname(pdev, irq_type->irq_name);
469465
if (irq < 0)
470466
return -EINVAL;
471467

472-
irq_data[i].dev = tps->dev;
473-
irq_data[i].type = irq_type;
468+
irq_data = devm_kmalloc(tps->dev, sizeof(*irq_data), GFP_KERNEL);
469+
if (!irq_data)
470+
return -ENOMEM;
471+
472+
irq_data->dev = tps->dev;
473+
irq_data->type = irq_type;
474474
error = devm_request_threaded_irq(tps->dev, irq, NULL,
475475
tps65219_regulator_irq_handler,
476476
IRQF_ONESHOT,
477477
irq_type->irq_name,
478-
&irq_data[i]);
478+
irq_data);
479479
if (error)
480480
return dev_err_probe(tps->dev, PTR_ERR(rdev),
481481
"Failed to request %s IRQ %d: %d\n",

0 commit comments

Comments
 (0)