Since regulator_get() can return an errno via regulator pointer, we
need to make sure we handle that case without passing bogus pointers
around.

Add code to convert mtl017->regulator to a dummy regulator if
regulator_get() fails.

Signed-off-by: Andrey Smirnov <[email protected]>
---
 drivers/video/mtl017.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/mtl017.c b/drivers/video/mtl017.c
index 085ea110b..423fb8e4f 100644
--- a/drivers/video/mtl017.c
+++ b/drivers/video/mtl017.c
@@ -244,6 +244,9 @@ static int mtl017_probe(struct device_d *dev)
        mtl017->client = to_i2c_client(dev);
        mtl017->regulator = regulator_get(dev, "vdd");
 
+       if (IS_ERR(mtl017->regulator))
+               mtl017->regulator = NULL;
+
        mtl017->enable_gpio = of_get_named_gpio_flags(dev->device_node,
                        "enable-gpios", 0, &flags);
        if (gpio_is_valid(mtl017->enable_gpio)) {
-- 
2.19.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to