Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Cc: stable@kernel.org

authored by

Dan Carpenter and committed by
Wolfram Sang
ac2b0813 8839e460

+1 -1
+1 -1
drivers/i2c/busses/i2c-amd-mp2-pci.c
··· 349 349 if (!privdata) 350 350 return -ENOMEM; 351 351 352 + privdata->pci_dev = pci_dev; 352 353 rc = amd_mp2_pci_init(privdata, pci_dev); 353 354 if (rc) 354 355 return rc; 355 356 356 357 mutex_init(&privdata->c2p_lock); 357 - privdata->pci_dev = pci_dev; 358 358 359 359 pm_runtime_set_autosuspend_delay(&pci_dev->dev, 1000); 360 360 pm_runtime_use_autosuspend(&pci_dev->dev);