Re: [PATCH v4 3/8] PCI/DPC: Initialize info->id in dpc_process_error()
From: Naveen Naidu
Date: Thu Oct 21 2021 - 12:31:43 EST
On 20/10, Bjorn Helgaas wrote:
> On Tue, Oct 05, 2021 at 10:48:10PM +0530, Naveen Naidu wrote:
> > 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.
> >
> > Initialize the "info->id" before passing it to aer_print_error()
> >
> > Fixes: 8aefa9b0d910 ("PCI/DPC: Print AER status in DPC event handling")
> > Signed-off-by: Naveen Naidu <naveennaidu479@xxxxxxxxx>
> > ---
> > drivers/pci/pcie/dpc.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> > index c556e7beafe3..df3f3a10f8bc 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,
> >
> > 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);
> > + pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &info.id);
> >
> > pci_info(pdev, "containment event, status:%#06x source:%#06x\n",
> > - status, source);
> > + status, 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. So I think we
> need to extract this reason before reading PCI_EXP_DPC_SOURCE_ID,
> e.g.,
>
> reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN) >> 1;
> if (reason == 1 || reason == 2)
> pci_read_config_word(pdev, cap + PCI_EXP_DPC_SOURCE_ID, &info.id);
> else
> info.id = 0;
>
Thank you for the review, I'll make this change when I send a v5 for the
patch series.
> > ext_reason = (status & PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT) >> 5;
> > --
> > 2.25.1
> >
> > _______________________________________________
> > Linux-kernel-mentees mailing list
> > Linux-kernel-mentees@xxxxxxxxxxxxxxxxxxxxxxxxx
> > https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees