Skip to content

Commit 2cb2705

Browse files
andy-shevmchehab
authored andcommitted
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: 803abec ("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>
1 parent 0e3e0c9 commit 2cb2705

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎drivers/media/pci/intel/ipu3/cio2-bridge.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,15 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
173173
int ret;
174174

175175
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
176-
if (!adev->status.enabled)
176+
if (!adev->status.enabled) {
177+
acpi_dev_put(adev);
177178
continue;
179+
}
178180

179181
if (bridge->n_sensors >= CIO2_NUM_PORTS) {
182+
acpi_dev_put(adev);
180183
dev_err(&cio2->dev, "Exceeded available CIO2 ports\n");
181-
cio2_bridge_unregister_sensors(bridge);
182-
ret = -EINVAL;
183-
goto err_out;
184+
return -EINVAL;
184185
}
185186

186187
sensor = &bridge->sensors[bridge->n_sensors];
@@ -228,7 +229,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
228229
software_node_unregister_nodes(sensor->swnodes);
229230
err_put_adev:
230231
acpi_dev_put(sensor->adev);
231-
err_out:
232232
return ret;
233233
}
234234

0 commit comments

Comments
 (0)