]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ACPI: processor: Fix previous acpi_processor_errata_piix4() fix
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 17 Mar 2026 20:39:05 +0000 (21:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:54 +0000 (11:08 +0100)
[ Upstream commit bf504b229cb8d534eccbaeaa23eba34c05131e25 ]

After commi f132e089fe89 ("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: f132e089fe89 ("ACPI: processor: Fix NULL-pointer dereference in acpi_processor_errata_piix4()")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Closes: https://lore.kernel.org/linux-acpi/938e2206-def5-4b7a-9b2c-d1fd37681d8a@roeck-us.net/
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5975693.DvuYhMxLoT@rafael.j.wysocki
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/acpi/acpi_processor.c

index d8674aee28c2e234004e3a6a67342078d2c7946e..848a012cd19fbbc0af96858d034aa94891dd9403 100644 (file)
@@ -113,6 +113,10 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
                                     PCI_ANY_ID, PCI_ANY_ID, NULL);
                if (ide_dev) {
                        errata.piix4.bmisx = pci_resource_start(ide_dev, 4);
+                       if (errata.piix4.bmisx)
+                               dev_dbg(&ide_dev->dev,
+                                       "Bus master activity detection (BM-IDE) erratum enabled\n");
+
                        pci_dev_put(ide_dev);
                }
 
@@ -131,20 +135,17 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
                if (isa_dev) {
                        pci_read_config_byte(isa_dev, 0x76, &value1);
                        pci_read_config_byte(isa_dev, 0x77, &value2);
-                       if ((value1 & 0x80) || (value2 & 0x80))
+                       if ((value1 & 0x80) || (value2 & 0x80)) {
                                errata.piix4.fdma = 1;
+                               dev_dbg(&isa_dev->dev,
+                                       "Type-F DMA livelock erratum (C3 disabled)\n");
+                       }
                        pci_dev_put(isa_dev);
                }
 
                break;
        }
 
-       if (ide_dev)
-               dev_dbg(&ide_dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n");
-
-       if (isa_dev)
-               dev_dbg(&isa_dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n");
-
        return 0;
 }