From: Charles Keepax Date: Thu, 17 Sep 2015 13:50:20 +0000 (+0100) Subject: regulator: core: Correct return value check in regulator_resolve_supply X-Git-Tag: v4.2.4~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6556d8cd9ec858a17a8ebcdcb686ee4dcfed075;p=thirdparty%2Fkernel%2Fstable.git regulator: core: Correct return value check in regulator_resolve_supply commit 23c3f310e897837aeb8ffe8700b803cb58e7b35d upstream. The ret pointer passed to regulator_dev_lookup is only filled with a valid error code if regulator_dev_lookup returned NULL. Currently regulator_resolve_supply checks this ret value before it checks if a regulator was returned, this can result in valid regulator lookups being ignored. Fixes: 6261b06de565 ("regulator: Defer lookup of supply to regulator_get") Signed-off-by: Charles Keepax Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 78387a6cbae59..3b7058242b71d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1376,15 +1376,15 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) return 0; r = regulator_dev_lookup(dev, rdev->supply_name, &ret); - if (ret == -ENODEV) { - /* - * No supply was specified for this regulator and - * there will never be one. - */ - return 0; - } - if (!r) { + if (ret == -ENODEV) { + /* + * No supply was specified for this regulator and + * there will never be one. + */ + return 0; + } + if (have_full_constraints()) { r = dummy_regulator_rdev; } else {