media: ipu3-cio2: Fix reference counting when looping over ACPI devices
When we continue, due to device is disabled, loop we have to drop
reference count. When we have an array full of devices we have to also
drop the reference count. Note, in this case the
cio2_bridge_unregister_sensors() is called by the caller.
Fixes: 803abec64e
("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver")
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
0e3e0c9369
commit
2cb2705cf7
|
@ -173,14 +173,15 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
|
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
|
||||||
if (!adev->status.enabled)
|
if (!adev->status.enabled) {
|
||||||
|
acpi_dev_put(adev);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (bridge->n_sensors >= CIO2_NUM_PORTS) {
|
if (bridge->n_sensors >= CIO2_NUM_PORTS) {
|
||||||
|
acpi_dev_put(adev);
|
||||||
dev_err(&cio2->dev, "Exceeded available CIO2 ports\n");
|
dev_err(&cio2->dev, "Exceeded available CIO2 ports\n");
|
||||||
cio2_bridge_unregister_sensors(bridge);
|
return -EINVAL;
|
||||||
ret = -EINVAL;
|
|
||||||
goto err_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor = &bridge->sensors[bridge->n_sensors];
|
sensor = &bridge->sensors[bridge->n_sensors];
|
||||||
|
@ -228,7 +229,6 @@ err_free_swnodes:
|
||||||
software_node_unregister_nodes(sensor->swnodes);
|
software_node_unregister_nodes(sensor->swnodes);
|
||||||
err_put_adev:
|
err_put_adev:
|
||||||
acpi_dev_put(sensor->adev);
|
acpi_dev_put(sensor->adev);
|
||||||
err_out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue