From: Jon Hunter Date: Thu, 21 Apr 2016 16:11:58 +0000 (+0100) Subject: regulator: core: Clear the supply pointer if enabling fails X-Git-Tag: release-20171130_firefly~4^2~100^2~1^2~10^2~31 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3e19487b9bf5076dcc2cd79da3dbd57b94d4e6b7;p=firefly-linux-kernel-4.4.55.git regulator: core: Clear the supply pointer if enabling fails commit 8e5356a73604f53da6a1e0756727cb8f9f7bba17 upstream. During the resolution of a regulator's supply, we may attempt to enable the supply if the regulator itself is already enabled. If enabling the supply fails, then we will call _regulator_put() for the supply. However, the pointer to the supply has not been cleared for the regulator and this will cause a crash if we then unregister the regulator and attempt to call regulator_put() a second time for the supply. Fix this by clearing the supply pointer if enabling the supply after fails when resolving the supply for a regulator. Signed-off-by: Jon Hunter Signed-off-by: Mark Brown Cc: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 88dbbeb8569b..f9b8c44677eb 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1519,6 +1519,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) ret = regulator_enable(rdev->supply); if (ret < 0) { _regulator_put(rdev->supply); + rdev->supply = NULL; return ret; } }