i2c: amd-mp2: fix device leak on probe()
Subsystems (3)
PATCH 1/1 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 [email protected] # 5.2
Cc Elie Morisse <[email protected]>
Signed-off-by Johan Hovold <[email protected]>
--- drivers/i2c/busses/i2c-amd-mp2-pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-amd-mp2-pci.c +6 -1
@@ -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);
Signature · 1 line
2.51.2