lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251121113714.4080-1-johan@kernel.org>
Date: Fri, 21 Nov 2025 12:37:14 +0100
From: Johan Hovold <johan@...nel.org>
To: Elie Morisse <syniurge@...il.com>,
	Shyam Sundar S K <shyam-sundar.s-k@....com>,
	Andi Shyti <andi.shyti@...nel.org>
Cc: Wolfram Sang <wsa@...nel.org>,
	linux-i2c@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Johan Hovold <johan@...nel.org>,
	stable@...r.kernel.org
Subject: [PATCH] i2c: amd-mp2: fix device leak on probe()

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@...r.kernel.org	# 5.2
Cc: Elie Morisse <syniurge@...il.com>
Signed-off-by: Johan Hovold <johan@...nel.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ