Commit 7df66d77 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Mauro Carvalho Chehab

media: v4l: mt9v032: Disable clock on error paths

mt9v032_power_on() leaves clk enabled in case of errors,
but it is not expected by its callers.
There is a similar problem in mt9v032_registered().

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent b48d908d
...@@ -294,14 +294,22 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032) ...@@ -294,14 +294,22 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
/* Reset the chip and stop data read out */ /* Reset the chip and stop data read out */
ret = regmap_write(map, MT9V032_RESET, 1); ret = regmap_write(map, MT9V032_RESET, 1);
if (ret < 0) if (ret < 0)
return ret; goto err;
ret = regmap_write(map, MT9V032_RESET, 0); ret = regmap_write(map, MT9V032_RESET, 0);
if (ret < 0) if (ret < 0)
return ret; goto err;
ret = regmap_write(map, MT9V032_CHIP_CONTROL,
MT9V032_CHIP_CONTROL_MASTER_MODE);
if (ret < 0)
goto err;
return 0;
return regmap_write(map, MT9V032_CHIP_CONTROL, err:
MT9V032_CHIP_CONTROL_MASTER_MODE); clk_disable_unprepare(mt9v032->clk);
return ret;
} }
static void mt9v032_power_off(struct mt9v032 *mt9v032) static void mt9v032_power_off(struct mt9v032 *mt9v032)
...@@ -876,6 +884,9 @@ static int mt9v032_registered(struct v4l2_subdev *subdev) ...@@ -876,6 +884,9 @@ static int mt9v032_registered(struct v4l2_subdev *subdev)
/* Read and check the sensor version */ /* Read and check the sensor version */
ret = regmap_read(mt9v032->regmap, MT9V032_CHIP_VERSION, &version); ret = regmap_read(mt9v032->regmap, MT9V032_CHIP_VERSION, &version);
mt9v032_power_off(mt9v032);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "Failed reading chip version\n"); dev_err(&client->dev, "Failed reading chip version\n");
return ret; return ret;
...@@ -894,8 +905,6 @@ static int mt9v032_registered(struct v4l2_subdev *subdev) ...@@ -894,8 +905,6 @@ static int mt9v032_registered(struct v4l2_subdev *subdev)
return -ENODEV; return -ENODEV;
} }
mt9v032_power_off(mt9v032);
dev_info(&client->dev, "%s detected at address 0x%02x\n", dev_info(&client->dev, "%s detected at address 0x%02x\n",
mt9v032->version->name, client->addr); mt9v032->version->name, client->addr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment