Skip to content

Commit 57964ba

Browse files
committed
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 <[email protected]> Tested-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent ca2426a commit 57964ba

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

drivers/pci/pcie/aer.c

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,40 +1290,35 @@ static void aer_isr_one_error_type(struct pci_dev *root,
12901290
* @e_src: pointer to an error source
12911291
*/
12921292
static void aer_isr_one_error(struct pci_dev *root,
1293-
struct aer_err_source *e_src)
1293+
struct aer_err_source *e_src)
12941294
{
1295-
struct aer_err_info e_info;
1295+
u32 status = e_src->status;
12961296

12971297
pci_rootport_aer_stats_incr(root, e_src);
12981298

12991299
/*
13001300
* There is a possibility that both correctable error and
13011301
* uncorrectable error being logged. Report correctable error first.
13021302
*/
1303-
if (e_src->status & PCI_ERR_ROOT_COR_RCV) {
1304-
e_info.id = ERR_COR_ID(e_src->id);
1305-
e_info.severity = AER_CORRECTABLE;
1306-
1307-
if (e_src->status & PCI_ERR_ROOT_MULTI_COR_RCV)
1308-
e_info.multi_error_valid = 1;
1309-
else
1310-
e_info.multi_error_valid = 0;
1303+
if (status & PCI_ERR_ROOT_COR_RCV) {
1304+
int multi = status & PCI_ERR_ROOT_MULTI_COR_RCV;
1305+
struct aer_err_info e_info = {
1306+
.id = ERR_COR_ID(e_src->id),
1307+
.severity = AER_CORRECTABLE,
1308+
.multi_error_valid = multi ? 1 : 0,
1309+
};
13111310

13121311
aer_isr_one_error_type(root, &e_info);
13131312
}
13141313

1315-
if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) {
1316-
e_info.id = ERR_UNCOR_ID(e_src->id);
1317-
1318-
if (e_src->status & PCI_ERR_ROOT_FATAL_RCV)
1319-
e_info.severity = AER_FATAL;
1320-
else
1321-
e_info.severity = AER_NONFATAL;
1322-
1323-
if (e_src->status & PCI_ERR_ROOT_MULTI_UNCOR_RCV)
1324-
e_info.multi_error_valid = 1;
1325-
else
1326-
e_info.multi_error_valid = 0;
1314+
if (status & PCI_ERR_ROOT_UNCOR_RCV) {
1315+
int fatal = status & PCI_ERR_ROOT_FATAL_RCV;
1316+
int multi = status & PCI_ERR_ROOT_MULTI_UNCOR_RCV;
1317+
struct aer_err_info e_info = {
1318+
.id = ERR_UNCOR_ID(e_src->id),
1319+
.severity = fatal ? AER_FATAL : AER_NONFATAL,
1320+
.multi_error_valid = multi ? 1 : 0,
1321+
};
13271322

13281323
aer_isr_one_error_type(root, &e_info);
13291324
}

0 commit comments

Comments
 (0)