Skip to contentSkip to conversation

i2c: i2c-amd-mp2-pci: Fix Oops in amd_mp2_pci_init() error handling

PATCH Superseded Dan Carpenter 1 participant 1 message Sep 5, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i2c-amd-mp2-pci: Fix Oops in amd_mp2_pci_init() error handling

The problem is that we dereference "privdata->pci_dev" when we print the error messages in amd_mp2_pci_init():

	dev_err(ndev_dev(privdata), "Failed to enable MP2 PCI device\n");
                ^^^^^^^^^^^^^^^^^
Fixes 529766e0a011 ("i2c: Add drivers for the AMD PCIe MP2 I2C controller")
---
 drivers/i2c/busses/i2c-amd-mp2-pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-amd-mp2-pci.c +3 -3
index 5e4800d72e00..6bbc89d0bb27 100644
@@ -349,13 +349,13 @@ static int amd_mp2_pci_probe(struct pci_dev *pci_dev,
 	if (!privdata)
 		return -ENOMEM;
 
+	mutex_init(&privdata->c2p_lock);
+	privdata->pci_dev = pci_dev;
+
 	rc = amd_mp2_pci_init(privdata, pci_dev);
 	if (rc)
 		return rc;
 
-	mutex_init(&privdata->c2p_lock);
-	privdata->pci_dev = pci_dev;
-
 	pm_runtime_set_autosuspend_delay(&pci_dev->dev, 1000);
 	pm_runtime_use_autosuspend(&pci_dev->dev);
 	pm_runtime_put_autosuspend(&pci_dev->dev);
Signature · 1 line
2.20.1