linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c / ACPI: fix resource leak in reconfiguration device addition
@ 2021-09-22 16:57 Jamie Iles
  2021-09-23  6:51 ` Mika Westerberg
  2021-09-29 20:56 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Jamie Iles @ 2021-09-22 16:57 UTC (permalink / raw)
  To: linux-i2c; +Cc: Jamie Iles, Octavian Purdila, Wolfram Sang, Mika Westerberg

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: 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure notifications")
Cc: Octavian Purdila <octavian.purdila@intel.com>
Cc: Wolfram Sang <wsa@kernel.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jamie Iles <quic_jiles@quicinc.com>
---
 drivers/i2c/i2c-core-acpi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 6f0aa0ed3241..74925621f239 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -422,6 +422,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))
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c / ACPI: fix resource leak in reconfiguration device addition
  2021-09-22 16:57 [PATCH] i2c / ACPI: fix resource leak in reconfiguration device addition Jamie Iles
@ 2021-09-23  6:51 ` Mika Westerberg
  2021-09-29 20:56 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2021-09-23  6:51 UTC (permalink / raw)
  To: Jamie Iles; +Cc: linux-i2c, Octavian Purdila, Wolfram Sang

On Wed, Sep 22, 2021 at 05:57:18PM +0100, Jamie Iles wrote:
> 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: 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure notifications")
> Cc: Octavian Purdila <octavian.purdila@intel.com>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c / ACPI: fix resource leak in reconfiguration device addition
  2021-09-22 16:57 [PATCH] i2c / ACPI: fix resource leak in reconfiguration device addition Jamie Iles
  2021-09-23  6:51 ` Mika Westerberg
@ 2021-09-29 20:56 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2021-09-29 20:56 UTC (permalink / raw)
  To: Jamie Iles; +Cc: linux-i2c, Octavian Purdila, Mika Westerberg

[-- Attachment #1: Type: text/plain, Size: 699 bytes --]

On Wed, Sep 22, 2021 at 05:57:18PM +0100, Jamie Iles wrote:
> 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: 525e6fabeae2 ("i2c / ACPI: add support for ACPI reconfigure notifications")
> Cc: Octavian Purdila <octavian.purdila@intel.com>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Jamie Iles <quic_jiles@quicinc.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-29 20:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 16:57 [PATCH] i2c / ACPI: fix resource leak in reconfiguration device addition Jamie Iles
2021-09-23  6:51 ` Mika Westerberg
2021-09-29 20:56 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).