regulator: core: don't crash if set_voltage fails
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 22 May 2016 21:44:47 +0000 (00:44 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 3 Jul 2016 00:23:25 +0000 (03:23 +0300)
it was calling list_voltage() with uninitialized selector

drivers/regulator/core.c

index 2dd9838..38d0c2c 100644 (file)
@@ -1745,7 +1745,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
                ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
                                                   &selector);
 
                ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
                                                   &selector);
 
-               if (rdev->desc->ops->list_voltage)
+               if (ret >= 0 && rdev->desc->ops->list_voltage)
                        selector = rdev->desc->ops->list_voltage(rdev,
                                                                 selector);
                else
                        selector = rdev->desc->ops->list_voltage(rdev,
                                                                 selector);
                else