Skip to content

Commit 12841f8

Browse files
vaibhav92mpe
authored andcommitted
cxl: Check if vphb exists before iterating over AFU devices
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") Cc: stable@vger.kernel.org # v4.3+ 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>
1 parent 4d6c51b commit 12841f8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/misc/cxl/pci.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,9 @@ static pci_ers_result_t cxl_vphb_error_detected(struct cxl_afu *afu,
20832083
/* There should only be one entry, but go through the list
20842084
* anyway
20852085
*/
2086+
if (afu->phb == NULL)
2087+
return result;
2088+
20862089
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
20872090
if (!afu_dev->driver)
20882091
continue;
@@ -2124,8 +2127,7 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev,
21242127
* Tell the AFU drivers; but we don't care what they
21252128
* say, we're going away.
21262129
*/
2127-
if (afu->phb != NULL)
2128-
cxl_vphb_error_detected(afu, state);
2130+
cxl_vphb_error_detected(afu, state);
21292131
}
21302132
return PCI_ERS_RESULT_DISCONNECT;
21312133
}
@@ -2265,6 +2267,9 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev)
22652267
if (cxl_afu_select_best_mode(afu))
22662268
goto err;
22672269

2270+
if (afu->phb == NULL)
2271+
continue;
2272+
22682273
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
22692274
/* Reset the device context.
22702275
* TODO: make this less disruptive
@@ -2327,6 +2332,9 @@ static void cxl_pci_resume(struct pci_dev *pdev)
23272332
for (i = 0; i < adapter->slices; i++) {
23282333
afu = adapter->afu[i];
23292334

2335+
if (afu->phb == NULL)
2336+
continue;
2337+
23302338
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
23312339
if (afu_dev->driver && afu_dev->driver->err_handler &&
23322340
afu_dev->driver->err_handler->resume)

0 commit comments

Comments
 (0)