Skip to content

Commit bf504b2

Browse files
committed
ACPI: processor: Fix previous acpi_processor_errata_piix4() fix
After commi f132e08 ("ACPI: processor: Fix NULL-pointer dereference in acpi_processor_errata_piix4()"), device pointers may be dereferenced after dropping references to the device objects pointed to by them, which may cause a use-after-free to occur. Moreover, debug messages about enabling the errata may be printed if the errata flags corresponding to them are unset. Address all of these issues by moving message printing to the points in the code where the errata flags are set. Fixes: f132e08 ("ACPI: processor: Fix NULL-pointer dereference in acpi_processor_errata_piix4()") Reported-by: Guenter Roeck <[email protected]> Closes: https://lore.kernel.org/linux-acpi/[email protected]/ Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent f338e77 commit bf504b2

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

drivers/acpi/acpi_processor.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
113113
PCI_ANY_ID, PCI_ANY_ID, NULL);
114114
if (ide_dev) {
115115
errata.piix4.bmisx = pci_resource_start(ide_dev, 4);
116+
if (errata.piix4.bmisx)
117+
dev_dbg(&ide_dev->dev,
118+
"Bus master activity detection (BM-IDE) erratum enabled\n");
119+
116120
pci_dev_put(ide_dev);
117121
}
118122

@@ -131,20 +135,17 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
131135
if (isa_dev) {
132136
pci_read_config_byte(isa_dev, 0x76, &value1);
133137
pci_read_config_byte(isa_dev, 0x77, &value2);
134-
if ((value1 & 0x80) || (value2 & 0x80))
138+
if ((value1 & 0x80) || (value2 & 0x80)) {
135139
errata.piix4.fdma = 1;
140+
dev_dbg(&isa_dev->dev,
141+
"Type-F DMA livelock erratum (C3 disabled)\n");
142+
}
136143
pci_dev_put(isa_dev);
137144
}
138145

139146
break;
140147
}
141148

142-
if (ide_dev)
143-
dev_dbg(&ide_dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n");
144-
145-
if (isa_dev)
146-
dev_dbg(&isa_dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n");
147-
148149
return 0;
149150
}
150151

0 commit comments

Comments
 (0)