--- v3
+++ v5
@@ -1,4 +1,4 @@
-In the dpc_process_error() path, info->id isn't initialized before being
+In the dpc_process_error() path, info.id isn't initialized before being
passed to aer_print_error(). In the corresponding AER path, it is
initialized in aer_isr_one_error().
@@ -8,19 +8,22 @@
CID 1461602 (#1 of 1): Uninitialized scalar variable (UNINIT)
8. uninit_use_in_call: Using uninitialized value info.id when calling aer_print_error.
-Initialize the "info->id" before passing it to aer_print_error()
+Also Per PCIe r5.0, sec 7.9.15.5, the Source ID is defined only when the
+Trigger Reason indicates ERR_NONFATAL or ERR_FATAL. Initialize the
+"info.id" based on the trigger reason before passing it to
+aer_print_error()
Fixes: 8aefa9b0d910 ("PCI/DPC: Print AER status in DPC event handling")
Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
---
- drivers/pci/pcie/dpc.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
+ drivers/pci/pcie/dpc.c | 16 ++++++++++++----
+ 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
-index c556e7beafe3..df3f3a10f8bc 100644
+index c556e7beafe3..6fa1b1eb4671 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
-@@ -262,14 +262,14 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
+@@ -262,16 +262,24 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
void dpc_process_error(struct pci_dev *pdev)
{
@@ -30,14 +33,25 @@
pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
- pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &source);
-+ pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &info.id);
++ reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
++
++ /*
++ * Per PCIe r5.0, sec 7.9.15.5, the Source ID is defined only when the
++ * Trigger Reason indicates ERR_NONFATAL or ERR_FATAL.
++ */
++ if (reason == 1 || reason == 2)
++ pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &info.id);
++ else
++ info.id = 0;
pci_info(pdev, "containment event, status:%#06x source:%#06x\n",
- status, source);
+ status, info.id);
- reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
+- reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5;
+ pci_warn(pdev, "%s detected\n",
+ (reason == 0) ? "unmasked uncorrectable error" :
--
2.25.1