regulator: fix race with probing of dummy regulator
Subsystems (2)
v3 cover regulator: fix race with probing of dummy regulator
These two patches are already in linux-next. I made a minor adjustment proposed by Doug. Can they still be updated?
PATCH v3 1/2 regulator: dummy: force synchronous probing
Sometimes I get a NULL pointer dereference at boot time in kobject_get() with the following call stack:
anatop_regulator_probe()
devm_regulator_register()
regulator_register()
regulator_resolve_supply()
kobject_get()
By placing some extra BUG_ON() statements I could verify that this is raised because probing of the 'dummy' regulator driver is not completed ('dummy_regulator_rdev' is still NULL).
In the JTAG debugger I can see that dummy_regulator_probe() and anatop_regulator_probe() can be run by different kernel threads (kworker/u4:*). I haven't further investigated whether this can be changed or if there are other possibilities to force synchronization between these two probe routines. On the other hand I don't expect much boot time penalty by probing the 'dummy' regulator synchronously.
---
v2:
- no changes
v3:
- no changes
drivers/regulator/dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/dummy.c +1 -1
@@ -60,7 +60,7 @@ static struct platform_driver dummy_regulator_driver = { .probe = dummy_regulator_probe, .driver = { .name = "reg-dummy", - .probe_type = PROBE_PREFER_ASYNCHRONOUS, + .probe_type = PROBE_FORCE_SYNCHRONOUS, }, };
Signature · 1 line
2.44.1
PATCH v3 2/2 regulator: check that dummy regulator has been probed before using it
In reply to Christian EggersDue to asynchronous driver probing there is a chance that the dummy regulator hasn't already been probed when first accessing it.
---
v2:
- return -EPROBE_DEFER rather than using BUG_ON()
v3:
- move dev_warn() below returning -EPROBE_DEFER
drivers/regulator/core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/regulator/core.c +11 -1
@@ -2069,6 +2069,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)if (have_full_constraints ()) { r = dummy_regulator_rdev; +if (!r) { + ret = -EPROBE_DEFER ; + goto out; + }get_device (&r->dev); }else { dev_err(dev, "Failed to resolve %s-supply for %s\n",
@@ -2086,6 +2090,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) goto out; } r = dummy_regulator_rdev; +if (!r) { + ret = -EPROBE_DEFER ; + goto out; + }get_device (&r->dev); }
@@ -2211,8 +2219,10 @@ struct regulator *_regulator_get_common(struct regulator_dev *rdev, struct devic* enabled, even if it isn't hooked up, and just * provide a dummy. */ -dev_warn (dev,"supply %s not found, using dummy regulator\n" , id); rdev = dummy_regulator_rdev; +if (!rdev) +return ERR_PTR (-EPROBE_DEFER ); +dev_warn (dev,"supply %s not found, using dummy regulator\n" , id);get_device (&rdev->dev);break ;
Signature · 1 line
2.44.1
Mark Brown
maintainerRe: [PATCH v3 2/2] regulator: check that dummy regulator has been probed before using it
Quoted 2 lines · Christian Eggers
Due to asynchronous driver probing there is a chance that the dummy regulator hasn't already been probed when first accessing it.
Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.
Mark Brown
maintainerRe: (subset) [PATCH v3 0/2] regulator: fix race with probing of dummy regulator
In reply to Christian EggersQuoted 3 lines · Christian Eggers
These two patches are already in linux-next. I made a minor adjustment proposed by Doug. Can they still be updated?
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[2/2] regulator: check that dummy regulator has been probed before using it
commit: 2c7a50bec4958f1d1c84d19cde518d0e96a676fd
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