Skip to content

Commit 2c7a50b

Browse files
ceggers-arribroonie
authored andcommitted
regulator: check that dummy regulator has been probed before using it
Due to asynchronous driver probing there is a chance that the dummy regulator hasn't already been probed when first accessing it. Cc: stable@vger.kernel.org Signed-off-by: Christian Eggers <ceggers@arri.de> Link: https://patch.msgid.link/20250313103051.32430-3-ceggers@arri.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8619909 commit 2c7a50b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/regulator/core.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
20742074

20752075
if (have_full_constraints()) {
20762076
r = dummy_regulator_rdev;
2077+
if (!r) {
2078+
ret = -EPROBE_DEFER;
2079+
goto out;
2080+
}
20772081
get_device(&r->dev);
20782082
} else {
20792083
dev_err(dev, "Failed to resolve %s-supply for %s\n",
@@ -2091,6 +2095,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
20912095
goto out;
20922096
}
20932097
r = dummy_regulator_rdev;
2098+
if (!r) {
2099+
ret = -EPROBE_DEFER;
2100+
goto out;
2101+
}
20942102
get_device(&r->dev);
20952103
}
20962104

@@ -2219,8 +2227,10 @@ struct regulator *_regulator_get_common(struct regulator_dev *rdev, struct devic
22192227
* enabled, even if it isn't hooked up, and just
22202228
* provide a dummy.
22212229
*/
2222-
dev_warn(dev, "supply %s not found, using dummy regulator\n", id);
22232230
rdev = dummy_regulator_rdev;
2231+
if (!rdev)
2232+
return ERR_PTR(-EPROBE_DEFER);
2233+
dev_warn(dev, "supply %s not found, using dummy regulator\n", id);
22242234
get_device(&rdev->dev);
22252235
break;
22262236

0 commit comments

Comments
 (0)