linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Naveen Naidu <naveennaidu479@gmail.com>
To: bhelgaas@google.com, ruscur@russell.cc, oohall@gmail.com
Cc: Oza Pawandeep <poza@codeaurora.org>,
	linux-pci@vger.kernel.org, Sinan Kaya <okaya@kernel.org>,
	linux-kernel@vger.kernel.org,
	Naveen Naidu <naveennaidu479@gmail.com>,
	skhan@linuxfoundation.org, Keith Busch <kbusch@kernel.org>,
	linuxppc-dev@lists.ozlabs.org,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: [PATCH v5 3/5] PCI/DPC: Initialize info.id in dpc_process_error()
Date: Mon, 25 Oct 2021 22:31:02 +0530	[thread overview]
Message-ID: <b486768a365ccef665b52fd9a1a2132006ab0f92.1635179600.git.naveennaidu479@gmail.com> (raw)
In-Reply-To: <cover.1635179600.git.naveennaidu479@gmail.com>

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().

The error message shown during Coverity Scan is:

  Coverity #1461602
  CID 1461602 (#1 of 1): Uninitialized scalar variable (UNINIT)
  8. uninit_use_in_call: Using uninitialized value info.id when calling 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 | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index c556e7beafe3..6fa1b1eb4671 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -262,16 +262,24 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
 
 void dpc_process_error(struct pci_dev *pdev)
 {
-	u16 cap = pdev->dpc_cap, status, source, reason, ext_reason;
+	u16 cap = pdev->dpc_cap, status, reason, ext_reason;
 	struct aer_err_info info;
 
 	pci_read_config_word(pdev, cap + PCI_EXP_DPC_STATUS, &status);
-	pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &source);
+	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;
 	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


  parent reply	other threads:[~2021-10-25 17:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 17:00 [PATCH v5 0/5] Fix long standing AER Error Handling Issues Naveen Naidu
2021-10-25 17:01 ` [PATCH v5 1/5] PCI/AER: Remove ID from aer_agent_string[] Naveen Naidu
2021-10-25 17:01 ` [PATCH v5 2/5] PCI: Cleanup struct aer_err_info Naveen Naidu
2021-10-25 17:01 ` Naveen Naidu [this message]
2021-10-25 17:01 ` [PATCH v5 4/5] PCI/AER: Clear error device AER registers in aer_irq() Naveen Naidu
2021-10-25 17:01 ` [PATCH v5 5/5] PCI/AER: Include DEVCTL in aer_print_error() Naveen Naidu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b486768a365ccef665b52fd9a1a2132006ab0f92.1635179600.git.naveennaidu479@gmail.com \
    --to=naveennaidu479@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=okaya@kernel.org \
    --cc=oohall@gmail.com \
    --cc=poza@codeaurora.org \
    --cc=ruscur@russell.cc \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).