From: Wentao Liang <vulab@iscas.ac.cn>
To: andy.shevchenko@gmail.com
Cc: linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, westeri@kernel.org,
wsa+renesas@sang-engineering.com,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] i2c: acpi: Fix adapter reference leak in i2c_acpi_new_device_by_fwnode()
Date: Wed, 16 Sep 2026 15:55:07 +0000 [thread overview]
Message-ID: <20260916155507.2074970-1-vulab@iscas.ac.cn> (raw)
i2c_acpi_find_adapter_by_handle() returns the adapter with a reference
obtained via get_device() in bus_find_device(), which the caller is
responsible for dropping. i2c_new_client_device() stores the adapter
pointer without taking a reference and does not release the caller's
reference on any path, so the reference is leaked.
Drop the adapter device reference after creating the client, like
i2c_acpi_notify() does.
Fixes: 53f8f7c5cf14 ("i2c: break out ACPI support into separate file")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/i2c/i2c-core-acpi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 28c0e4884a7f..5efd1c406bc2 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -544,6 +544,7 @@ struct i2c_client *i2c_acpi_new_device_by_fwnode(struct fwnode_handle *fwnode,
struct i2c_board_info *info)
{
struct i2c_acpi_lookup lookup;
+ struct i2c_client *client;
struct i2c_adapter *adapter;
struct acpi_device *adev;
LIST_HEAD(resource_list);
@@ -572,7 +573,10 @@ struct i2c_client *i2c_acpi_new_device_by_fwnode(struct fwnode_handle *fwnode,
if (!adapter)
return ERR_PTR(-EPROBE_DEFER);
- return i2c_new_client_device(adapter, info);
+ client = i2c_new_client_device(adapter, info);
+ put_device(&adapter->dev);
+
+ return client;
}
EXPORT_SYMBOL_GPL(i2c_acpi_new_device_by_fwnode);
--
2.34.1
next reply other threads:[~2026-09-16 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:55 Wentao Liang [this message]
2026-09-17 6:57 ` [PATCH] i2c: acpi: Fix adapter reference leak in i2c_acpi_new_device_by_fwnode() Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260916155507.2074970-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andy.shevchenko@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=westeri@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.