Skip to content

Commit 76fcdc8

Browse files
vaibhav92gregkh
authored andcommitted
cxl: Check if vphb exists before iterating over AFU devices
commit 12841f8 upstream. During an eeh a kernel-oops is reported if no vPHB is allocated to the AFU. This happens as during AFU init, an error in creation of vPHB is a non-fatal error. Hence afu->phb should always be checked for NULL before iterating over it for the virtual AFU pci devices. This patch fixes the kenel-oops by adding a NULL pointer check for afu->phb before it is dereferenced. Fixes: 9e8df8a ("cxl: EEH support") Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b632d71 commit 76fcdc8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/misc/cxl/pci.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,9 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
17581758
/* There should only be one entry, but go through the list
17591759
* anyway
17601760
*/
1761+
if (afu->phb == NULL)
1762+
return result;
1763+
17611764
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
17621765
if (!afu_dev->driver)
17631766
continue;
@@ -1801,6 +1804,11 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
18011804
/* Only participate in EEH if we are on a virtual PHB */
18021805
if (afu->phb == NULL)
18031806
return PCI_ERS_RESULT_NONE;
1807+
1808+
/*
1809+
* Tell the AFU drivers; but we don't care what they
1810+
* say, we're going away.
1811+
*/
18041812
cxl_vphb_error_detected(afu, state);
18051813
}
18061814
return PCI_ERS_RESULT_DISCONNECT;
@@ -1941,6 +1949,9 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
19411949
if (cxl_afu_select_best_mode(afu))
19421950
goto err;
19431951

1952+
if (afu->phb == NULL)
1953+
continue;
1954+
19441955
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
19451956
/* Reset the device context.
19461957
* TODO: make this less disruptive
@@ -2003,6 +2014,9 @@ static void cxl_pci_resume(struct pci_dev *pdev)
20032014
for (i = 0; i < adapter->slices; i++) {
20042015
afu = adapter->afu[i];
20052016

2017+
if (afu->phb == NULL)
2018+
continue;
2019+
20062020
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
20072021
if (afu_dev->driver && afu_dev->driver->err_handler &&
20082022
afu_dev->driver->err_handler->resume)

0 commit comments

Comments
 (0)