From: Johan Hovold <johan@kernel.org>
To: Elie Morisse <syniurge@gmail.com>,
Shyam Sundar S K <shyam-sundar.s-k@amd.com>,
Andi Shyti <andi.shyti@kernel.org>
Cc: Wolfram Sang <wsa@kernel.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH] i2c: amd-mp2: fix device leak on probe()
Date: Fri, 21 Nov 2025 12:37:14 +0100 [thread overview]
Message-ID: <20251121113714.4080-1-johan@kernel.org> (raw)
Make sure to drop the reference taken to the PCI device when looking up
its driver data during probe of the platform device.
Note that holding a reference to a device does not prevent its driver
data from going away so there is no point in keeping the reference.
Fixes: 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
Cc: stable@vger.kernel.org # 5.2
Cc: Elie Morisse <syniurge@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/i2c/busses/i2c-amd-mp2-pci.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
index ef7370d3dbea..5b41d18b62d3 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
@@ -456,6 +456,7 @@ module_pci_driver(amd_mp2_pci_driver);
struct amd_mp2_dev *amd_mp2_find_device(void)
{
+ struct amd_mp2_dev *privdata;
struct device *dev;
struct pci_dev *pci_dev;
@@ -464,7 +465,11 @@ struct amd_mp2_dev *amd_mp2_find_device(void)
return NULL;
pci_dev = to_pci_dev(dev);
- return (struct amd_mp2_dev *)pci_get_drvdata(pci_dev);
+ privdata = pci_get_drvdata(pci_dev);
+
+ put_device(dev);
+
+ return privdata;
}
EXPORT_SYMBOL_GPL(amd_mp2_find_device);
--
2.51.2
reply other threads:[~2025-11-21 11:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251121113714.4080-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=andi.shyti@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shyam-sundar.s-k@amd.com \
--cc=stable@vger.kernel.org \
--cc=syniurge@gmail.com \
--cc=wsa@kernel.org \
/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 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).