Skip to content

Commit

Permalink
i2c: acpi: fix resource leak in reconfiguration device addition
Browse files Browse the repository at this point in the history
acpi_i2c_find_adapter_by_handle() calls bus_find_device() which takes a
reference on the adapter which is never released which will result in a
reference count leak and render the adapter unremovable.  Make sure to
put the adapter after creating the client in the same manner that we do
for OF.

Fixes: 525e6fa ("i2c / ACPI: add support for ACPI reconfigure notifications")
Signed-off-by: Jamie Iles <quic_jiles@quicinc.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
[wsa: fixed title]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
  • Loading branch information
Jamie Iles authored and Wolfram Sang committed Oct 2, 2021
1 parent 5816b3e commit 6558b64
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/i2c/i2c-core-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ static int i2c_acpi_notify(struct notifier_block *nb, unsigned long value,
break;

i2c_acpi_register_device(adapter, adev, &info);
put_device(&adapter->dev);
break;
case ACPI_RECONFIG_DEVICE_REMOVE:
if (!acpi_device_enumerated(adev))
Expand Down

0 comments on commit 6558b64

Please sign in to comment.