diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2025-05-22 18:21:14 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2025-05-23 11:01:06 -0500 |
commit | 57964ba39057a76f3485437347bb4219be9c5b52 (patch) | |
tree | f4fc0613505f63962c75d67375137796d087a266 | |
parent | ca2426a570ab4bdf6185aea034ee09184420bd0d (diff) |
PCI/AER: Initialize aer_err_info before using it
Previously the struct aer_err_info "e_info" was allocated on the stack
without being initialized, so it contained junk except for the fields we
explicitly set later.
Initialize "e_info" at declaration with a designated initializer list,
which initializes the other members to zero.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://patch.msgid.link/20250522232339.1525671-9-helgaas@kernel.org
-rw-r--r-- | drivers/pci/pcie/aer.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index c0481550363b..109f5e0ade8a 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1290,9 +1290,9 @@ static void aer_isr_one_error_type(struct pci_dev *root, * @e_src: pointer to an error source */ static void aer_isr_one_error(struct pci_dev *root, - struct aer_err_source *e_src) + struct aer_err_source *e_src) { - struct aer_err_info e_info; + u32 status = e_src->status; pci_rootport_aer_stats_incr(root, e_src); @@ -1300,30 +1300,25 @@ static void aer_isr_one_error(struct pci_dev *root, * There is a possibility that both correctable error and * uncorrectable error being logged. Report correctable error first. */ - if (e_src->status & PCI_ERR_ROOT_COR_RCV) { - e_info.id = ERR_COR_ID(e_src->id); - e_info.severity = AER_CORRECTABLE; - - if (e_src->status & PCI_ERR_ROOT_MULTI_COR_RCV) - e_info.multi_error_valid = 1; - else - e_info.multi_error_valid = 0; + if (status & PCI_ERR_ROOT_COR_RCV) { + int multi = status & PCI_ERR_ROOT_MULTI_COR_RCV; + struct aer_err_info e_info = { + .id = ERR_COR_ID(e_src->id), + .severity = AER_CORRECTABLE, + .multi_error_valid = multi ? 1 : 0, + }; aer_isr_one_error_type(root, &e_info); } - if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) { - e_info.id = ERR_UNCOR_ID(e_src->id); - - if (e_src->status & PCI_ERR_ROOT_FATAL_RCV) - e_info.severity = AER_FATAL; - else - e_info.severity = AER_NONFATAL; - - if (e_src->status & PCI_ERR_ROOT_MULTI_UNCOR_RCV) - e_info.multi_error_valid = 1; - else - e_info.multi_error_valid = 0; + if (status & PCI_ERR_ROOT_UNCOR_RCV) { + int fatal = status & PCI_ERR_ROOT_FATAL_RCV; + int multi = status & PCI_ERR_ROOT_MULTI_UNCOR_RCV; + struct aer_err_info e_info = { + .id = ERR_UNCOR_ID(e_src->id), + .severity = fatal ? AER_FATAL : AER_NONFATAL, + .multi_error_valid = multi ? 1 : 0, + }; aer_isr_one_error_type(root, &e_info); } |