From 426ba13f41e59151dce5d20dca1d4279192b60dc Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 12 Dec 2018 23:10:33 -0800 Subject: video: mtl017: Make sure errno is not used as a regulator pointer 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 Signed-off-by: Sascha Hauer --- drivers/video/mtl017.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/video') diff --git a/drivers/video/mtl017.c b/drivers/video/mtl017.c index 085ea110ba..423fb8e4fd 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)) { -- cgit v1.2.3