regulator: core: fix race condition in regulator_put()
[pandora-kernel.git] / drivers / regulator / core.c
index 6ec610c..adba3d6 100644 (file)
@@ -1314,12 +1314,14 @@ void regulator_put(struct regulator *regulator)
                device_remove_file(regulator->dev, &regulator->dev_attr);
                kfree(regulator->dev_attr.attr.name);
        }
                device_remove_file(regulator->dev, &regulator->dev_attr);
                kfree(regulator->dev_attr.attr.name);
        }
+       mutex_lock(&rdev->mutex);
        kfree(regulator->supply_name);
        list_del(&regulator->list);
        kfree(regulator);
 
        rdev->open_count--;
        rdev->exclusive = 0;
        kfree(regulator->supply_name);
        list_del(&regulator->list);
        kfree(regulator);
 
        rdev->open_count--;
        rdev->exclusive = 0;
+       mutex_unlock(&rdev->mutex);
 
        module_put(rdev->owner);
        mutex_unlock(&regulator_list_mutex);
 
        module_put(rdev->owner);
        mutex_unlock(&regulator_list_mutex);