]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
regulator: core: Move regulator release to avoid deadlock
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Mon, 29 Oct 2012 09:33:33 +0000 (09:33 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 29 Oct 2012 16:12:39 +0000 (16:12 +0000)
regulator_put function was called whilst holding the
regulator_list_mutex, which is also locked from regulator_put. This
causes deadlock when failing to register a regulator.

This patch adds a second exit point for the regulator_register function
which releases the mutex and then cleans up the supply.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c

index 5c4829cba6a62de6168c6bb3c4913812e5e8b4e1..e68754cfadc8e73801b77aec448b09965de8f4f0 100644 (file)
@@ -3444,15 +3444,18 @@ unset_supplies:
        unset_regulator_supplies(rdev);
 
 scrub:
-       if (rdev->supply)
-               regulator_put(rdev->supply);
        if (rdev->ena_gpio)
                gpio_free(rdev->ena_gpio);
        kfree(rdev->constraints);
        device_unregister(&rdev->dev);
+
+       mutex_unlock(&regulator_list_mutex);
+       if (rdev->supply)
+               regulator_put(rdev->supply);
+
        /* device core frees rdev */
        rdev = ERR_PTR(ret);
-       goto out;
+       return rdev;
 
 clean:
        kfree(rdev);