diff mbox series

media: ov2680: fix null dereference at power on

Message ID 20181121105955.9217-1-rui.silva@linaro.org (mailing list archive)
State New, archived
Headers show
Series media: ov2680: fix null dereference at power on | expand

Commit Message

Rui Miguel Silva Nov. 21, 2018, 10:59 a.m. UTC
Swapping the order between v4l2 subdevice registration and checking chip id in
b7a417628abf ("media: ov2680: don't register the v4l2 subdevice before checking chip ID")
makes the mode restore to use the sensor controls before they are set, so move
the mode restore call to s_power after the handler setup for controls is done.

This remove also the need for the error code path in power on function.

Fixes: b7a417628abf ("media: ov2680: don't register the v4l2 subdevice before checking chip ID")

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
 drivers/media/i2c/ov2680.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

Sakari Ailus Nov. 22, 2018, 10:52 a.m. UTC | #1
Hi Rui,

On Wed, Nov 21, 2018 at 10:59:55AM +0000, Rui Miguel Silva wrote:
> Swapping the order between v4l2 subdevice registration and checking chip id in
> b7a417628abf ("media: ov2680: don't register the v4l2 subdevice before checking chip ID")
> makes the mode restore to use the sensor controls before they are set, so move
> the mode restore call to s_power after the handler setup for controls is done.
> 
> This remove also the need for the error code path in power on function.

Could you make sure you wrap the lines in the commit at 76 or so? Otherwise
they'll wrap in git log. I've re-wrapped it this time.

Thanks.
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 0e34e15b67b3..b10bcfabaeeb 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -568,10 +568,6 @@  static int ov2680_power_on(struct ov2680_dev *sensor)
 	if (ret < 0)
 		return ret;
 
-	ret = ov2680_mode_restore(sensor);
-	if (ret < 0)
-		goto disable;
-
 	sensor->is_enabled = true;
 
 	/* Set clock lane into LP-11 state */
@@ -580,12 +576,6 @@  static int ov2680_power_on(struct ov2680_dev *sensor)
 	ov2680_stream_disable(sensor);
 
 	return 0;
-
-disable:
-	dev_err(dev, "failed to enable sensor: %d\n", ret);
-	ov2680_power_off(sensor);
-
-	return ret;
 }
 
 static int ov2680_s_power(struct v4l2_subdev *sd, int on)
@@ -606,6 +596,8 @@  static int ov2680_s_power(struct v4l2_subdev *sd, int on)
 		ret = v4l2_ctrl_handler_setup(&sensor->ctrls.handler);
 		if (ret < 0)
 			return ret;
+
+		ret = ov2680_mode_restore(sensor);
 	}
 
 	return ret;