Commit c45fbdf2 authored by Rui Miguel Silva's avatar Rui Miguel Silva Committed by Mauro Carvalho Chehab
Browse files

media: ov2680: fix null dereference at power on



Swapping the order between v4l2 subdevice registration and checking chip
id in b7a41762 ("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: b7a41762 ("media: ov2680: don't register the v4l2 subdevice before checking chip ID")

Signed-off-by: default avatarRui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5f229dca
Loading
Loading
Loading
Loading
+2 −10
Original line number Original line Diff line number Diff line
@@ -568,10 +568,6 @@ static int ov2680_power_on(struct ov2680_dev *sensor)
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;


	ret = ov2680_mode_restore(sensor);
	if (ret < 0)
		goto disable;

	sensor->is_enabled = true;
	sensor->is_enabled = true;


	/* Set clock lane into LP-11 state */
	/* Set clock lane into LP-11 state */
@@ -580,12 +576,6 @@ static int ov2680_power_on(struct ov2680_dev *sensor)
	ov2680_stream_disable(sensor);
	ov2680_stream_disable(sensor);


	return 0;
	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)
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);
		ret = v4l2_ctrl_handler_setup(&sensor->ctrls.handler);
		if (ret < 0)
		if (ret < 0)
			return ret;
			return ret;

		ret = ov2680_mode_restore(sensor);
	}
	}


	return ret;
	return ret;