regulator: core: Fix locking of GPIO list on free
authorMark Brown <broonie@kernel.org>
Tue, 12 Apr 2016 07:05:43 +0000 (08:05 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 13 Apr 2016 06:43:00 +0000 (07:43 +0100)
When we acquire a shareable enable GPIO on probe we do so with the
regulator_list_mutex held.  However when we release the GPIOs we do this
immediately after dropping the mutex meaning that the list could become
corrupted.  Move the release into the locked region to avoid this.

Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index 1cff112056429820fbe1801ffdfbbd60178133c0..e414c24b290603b447c824d7c67ef5c5b687c0db 100644 (file)
@@ -4021,8 +4021,8 @@ void regulator_unregister(struct regulator_dev *rdev)
        WARN_ON(rdev->open_count);
        unset_regulator_supplies(rdev);
        list_del(&rdev->list);
-       mutex_unlock(&regulator_list_mutex);
        regulator_ena_gpio_free(rdev);
+       mutex_unlock(&regulator_list_mutex);
        device_unregister(&rdev->dev);
 }
 EXPORT_SYMBOL_GPL(regulator_unregister);