regulator: core: lock device when calling device_is_bound()
PATCH 1/1 regulator: core: lock device when calling device_is_bound()
device_is_bound() must be called with the device lock taken. Add missing synchronization in regulator_resolve_supply().
--- drivers/regulator/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/regulator/core.c +6 -4
@@ -2240,10 +2240,12 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)* device get probe deferred and unregisters the supply. */ if (r->dev.parent && r->dev.parent != rdev->dev.parent) { -if (!device_is_bound (r->dev.parent)) { -put_device (&r->dev); - ret = -EPROBE_DEFER ; - goto out; + scoped_guard(device, r->dev.parent) { +if (!device_is_bound (r->dev.parent)) { +put_device (&r->dev); + ret = -EPROBE_DEFER ; + goto out; + } } }
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 4 lines · Bartosz Golaszewski
drivers/regulator/core.c +0
-0@@ -2240,10 +2240,12 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)* device get probe deferred and unregisters the supply. */ if (r->dev.parent && r->dev.parent != rdev->dev.parent) {
drivers/regulator/core.c static int regulator_resolve_supply(struct regulator_dev *rdev) · line 2248
Quoted 10 lines
drivers/regulator/core.c +6
-4-if (!device_is_bound (r->dev.parent)) { -put_device (&r->dev); - ret = -EPROBE_DEFER ; - goto out; + scoped_guard(device, r->dev.parent) { +if (!device_is_bound (r->dev.parent)) { +put_device (&r->dev); + ret = -EPROBE_DEFER ; + goto out; + }
How does this work if a regulator is being registered in the context of a MFD registering it's children from probe()?
I'm also not convinced that mixing a scoped guard into the middle of goto based cleanup is the best thing.
Quoted 12 lines · Mark Brown
Quoted 9 lines · Bartosz Golaszewski
drivers/regulator/core.c +1
-4@@ -2240,10 +2240,12 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)* device get probe deferred and unregisters the supply. */ if (r->dev.parent && r->dev.parent != rdev->dev.parent) { -if (!device_is_bound (r->dev.parent)) { -put_device (&r->dev); - ret = -EPROBE_DEFER ; - goto out; + scoped_guard(device, r->dev.parent) {
Quoted 9 lines
drivers/regulator/core.c static int regulator_resolve_supply(struct regulator_dev *rdev) · line 2248
Quoted 5 lines
drivers/regulator/core.c +5
-0+if (!device_is_bound (r->dev.parent)) { +put_device (&r->dev); + ret = -EPROBE_DEFER ; + goto out; + }How does this work if a regulator is being registered in the context of a MFD registering it's children from
probe()?
Yeah, I've seen the comment from sashiko. I don't have an idea that doesn't involve a serious rework, so we may drop this patch. After all it worked without issues so far.
Bart
Quoted 2 lines
I'm also not convinced that mixing a scoped guard into the middle of goto based cleanup is the best thing.