regulator: core: Increase refcount for regulator supply's module
authorJavier Martinez Canillas <javier@osg.samsung.com>
Wed, 15 Jul 2015 14:10:28 +0000 (16:10 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 16 Jul 2015 20:38:59 +0000 (21:38 +0100)
When a regulator is unregistered with regulator_unregister(), a call to
regulator_put() is made for its input supply if there is one. This does
a module_put() to decrement the refcount of the module that owns the
supply but there isn't a corresponding try_module_get() in set_supply()
to make the calls balanced.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index c9f72019bd689afbb4e51528932689dc097b191b..934fde4faebe6c8204e1f9ca2f0b3b39caca6a2a 100644 (file)
@@ -1105,6 +1105,9 @@ static int set_supply(struct regulator_dev *rdev,
 
        rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev));
 
+       if (!try_module_get(supply_rdev->owner))
+               return -ENODEV;
+
        rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
        if (rdev->supply == NULL) {
                err = -ENOMEM;