regulator: Fix possible nullpointer dereference in regulator_enable()
authorHeiko Stübner <heiko@sntech.de>
Fri, 14 Oct 2011 16:00:29 +0000 (18:00 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 14 Oct 2011 19:47:06 +0000 (20:47 +0100)
In the case where _regulator_enable returns an error it was not checked
if a supplying regulator exists before trying to disable it, leading
to a null pointer-dereference if no supplying regulator existed.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c

index 9a33fe2..87d9328 100644 (file)
@@ -1425,7 +1425,7 @@ int regulator_enable(struct regulator *regulator)
        ret = _regulator_enable(rdev);
        mutex_unlock(&rdev->mutex);
 
-       if (ret != 0)
+       if (ret != 0 && rdev->supply)
                regulator_disable(rdev->supply);
 
        return ret;