[PATCH 3/3] video: mtl017: Make sure errno is not used as a regulator pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <andrew.smirnov@xxxxxxxxx>
---
 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
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux