Commit 54ade663 authored by Bingbu Cao's avatar Bingbu Cao Committed by Mauro Carvalho Chehab

media: ov2740: identify module after subdev initialisation

The module identifying will try to get the sub device data which
will be ready after sub device initialisation, so if try to use the
subdev data to deference the client will cause NULL pointer
dereference, this patch move the module identification after
v4l2_i2c_subdev_init() to fix this issue, it also fixes duplicate
module idendification.

Fixes: ada2c4f5 ("media: ov2740: support device probe in non-zero ACPI D state")
Signed-off-by: default avatarBingbu Cao <bingbu.cao@intel.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent e9b06e21
...@@ -1162,6 +1162,7 @@ static int ov2740_probe(struct i2c_client *client) ...@@ -1162,6 +1162,7 @@ static int ov2740_probe(struct i2c_client *client)
if (!ov2740) if (!ov2740)
return -ENOMEM; return -ENOMEM;
v4l2_i2c_subdev_init(&ov2740->sd, client, &ov2740_subdev_ops);
full_power = acpi_dev_state_d0(&client->dev); full_power = acpi_dev_state_d0(&client->dev);
if (full_power) { if (full_power) {
ret = ov2740_identify_module(ov2740); ret = ov2740_identify_module(ov2740);
...@@ -1171,13 +1172,6 @@ static int ov2740_probe(struct i2c_client *client) ...@@ -1171,13 +1172,6 @@ static int ov2740_probe(struct i2c_client *client)
} }
} }
v4l2_i2c_subdev_init(&ov2740->sd, client, &ov2740_subdev_ops);
ret = ov2740_identify_module(ov2740);
if (ret) {
dev_err(&client->dev, "failed to find sensor: %d", ret);
return ret;
}
mutex_init(&ov2740->mutex); mutex_init(&ov2740->mutex);
ov2740->cur_mode = &supported_modes[0]; ov2740->cur_mode = &supported_modes[0];
ret = ov2740_init_controls(ov2740); ret = ov2740_init_controls(ov2740);
......
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