From ec37d1eeaddbdd68dbb37e31d9cab99a231238b3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 12 Jul 2025 16:55:33 +0200 Subject: [PATCH] 6.15-stable patches added patches: revert-acpi-battery-negate-current-when-discharging.patch revert-pci-acpi-fix-allocated-memory-release-on-error-in-pci_acpi_scan_root.patch --- ...tery-negate-current-when-discharging.patch | 51 ++++++++++++ ...lease-on-error-in-pci_acpi_scan_root.patch | 81 +++++++++++++++++++ queue-6.15/series | 2 + 3 files changed, 134 insertions(+) create mode 100644 queue-6.15/revert-acpi-battery-negate-current-when-discharging.patch create mode 100644 queue-6.15/revert-pci-acpi-fix-allocated-memory-release-on-error-in-pci_acpi_scan_root.patch diff --git a/queue-6.15/revert-acpi-battery-negate-current-when-discharging.patch b/queue-6.15/revert-acpi-battery-negate-current-when-discharging.patch new file mode 100644 index 0000000000..d2a0f591c1 --- /dev/null +++ b/queue-6.15/revert-acpi-battery-negate-current-when-discharging.patch @@ -0,0 +1,51 @@ +From de1675de39aa945bad5937d1fde4df3682670639 Mon Sep 17 00:00:00 2001 +From: "Rafael J. Wysocki" +Date: Thu, 3 Jul 2025 12:54:55 +0200 +Subject: Revert "ACPI: battery: negate current when discharging" + +From: Rafael J. Wysocki + +commit de1675de39aa945bad5937d1fde4df3682670639 upstream. + +Revert commit 234f71555019 ("ACPI: battery: negate current when +discharging") breaks not one but several userspace implementations +of battery monitoring: Steam and MangoHud. Perhaps it breaks more, +but those are the two that have been tested. + +Reported-by: Matthew Schwartz +Closes: https://lore.kernel.org/linux-acpi/87C1B2AF-D430-4568-B620-14B941A8ABA4@linux.dev/ +Signed-off-by: Rafael J. Wysocki +Signed-off-by: Greg Kroah-Hartman +--- + drivers/acpi/battery.c | 19 +++---------------- + 1 file changed, 3 insertions(+), 16 deletions(-) + +--- a/drivers/acpi/battery.c ++++ b/drivers/acpi/battery.c +@@ -243,23 +243,10 @@ static int acpi_battery_get_property(str + break; + case POWER_SUPPLY_PROP_CURRENT_NOW: + case POWER_SUPPLY_PROP_POWER_NOW: +- if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) { ++ if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) + ret = -ENODEV; +- break; +- } +- +- val->intval = battery->rate_now * 1000; +- /* +- * When discharging, the current should be reported as a +- * negative number as per the power supply class interface +- * definition. +- */ +- if (psp == POWER_SUPPLY_PROP_CURRENT_NOW && +- (battery->state & ACPI_BATTERY_STATE_DISCHARGING) && +- acpi_battery_handle_discharging(battery) +- == POWER_SUPPLY_STATUS_DISCHARGING) +- val->intval = -val->intval; +- ++ else ++ val->intval = battery->rate_now * 1000; + break; + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: + case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: diff --git a/queue-6.15/revert-pci-acpi-fix-allocated-memory-release-on-error-in-pci_acpi_scan_root.patch b/queue-6.15/revert-pci-acpi-fix-allocated-memory-release-on-error-in-pci_acpi_scan_root.patch new file mode 100644 index 0000000000..7a3bf67be2 --- /dev/null +++ b/queue-6.15/revert-pci-acpi-fix-allocated-memory-release-on-error-in-pci_acpi_scan_root.patch @@ -0,0 +1,81 @@ +From 2b8be57fa0c88ac824a906f29c04d728f9f6047a Mon Sep 17 00:00:00 2001 +From: Zhe Qiao +Date: Thu, 19 Jun 2025 15:26:08 +0800 +Subject: Revert "PCI/ACPI: Fix allocated memory release on error in pci_acpi_scan_root()" + +From: Zhe Qiao + +commit 2b8be57fa0c88ac824a906f29c04d728f9f6047a upstream. + +This reverts commit 631b2af2f357 ("PCI/ACPI: Fix allocated memory release +on error in pci_acpi_scan_root()"). + +The reverted patch causes the 'ri->cfg' and 'root_ops' resources to be +released multiple times. + +When acpi_pci_root_create() fails, these resources have already been +released internally by the __acpi_pci_root_release_info() function. + +Releasing them again in pci_acpi_scan_root() leads to incorrect behavior +and potential memory issues. + +We plan to resolve the issue using a more appropriate fix. + +Reported-by: Dan Carpenter +Closes: https://lore.kernel.org/all/aEmdnuw715btq7Q5@stanley.mountain/ +Signed-off-by: Zhe Qiao +Acked-by: Dan Carpenter +Link: https://patch.msgid.link/20250619072608.2075475-1-qiaozhe@iscas.ac.cn +Signed-off-by: Rafael J. Wysocki +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/pci-acpi.c | 23 ++++++++++------------- + 1 file changed, 10 insertions(+), 13 deletions(-) + +--- a/drivers/pci/pci-acpi.c ++++ b/drivers/pci/pci-acpi.c +@@ -1676,19 +1676,24 @@ struct pci_bus *pci_acpi_scan_root(struc + return NULL; + + root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL); +- if (!root_ops) +- goto free_ri; ++ if (!root_ops) { ++ kfree(ri); ++ return NULL; ++ } + + ri->cfg = pci_acpi_setup_ecam_mapping(root); +- if (!ri->cfg) +- goto free_root_ops; ++ if (!ri->cfg) { ++ kfree(ri); ++ kfree(root_ops); ++ return NULL; ++ } + + root_ops->release_info = pci_acpi_generic_release_info; + root_ops->prepare_resources = pci_acpi_root_prepare_resources; + root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops; + bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); + if (!bus) +- goto free_cfg; ++ return NULL; + + /* If we must preserve the resource configuration, claim now */ + host = pci_find_host_bridge(bus); +@@ -1705,14 +1710,6 @@ struct pci_bus *pci_acpi_scan_root(struc + pcie_bus_configure_settings(child); + + return bus; +- +-free_cfg: +- pci_ecam_free(ri->cfg); +-free_root_ops: +- kfree(root_ops); +-free_ri: +- kfree(ri); +- return NULL; + } + + void pcibios_add_bus(struct pci_bus *bus) diff --git a/queue-6.15/series b/queue-6.15/series index 5cf58f6eed..a9d3f6dc47 100644 --- a/queue-6.15/series +++ b/queue-6.15/series @@ -93,3 +93,5 @@ usb-gadget-u_serial-fix-race-condition-in-tty-wakeup.patch revert-usb-gadget-u_serial-add-null-pointer-check-in-gs_start_io.patch drm-framebuffer-acquire-internal-references-on-gem-handles.patch drm-xe-allocate-pf-queue-size-on-pow2-boundary.patch +revert-acpi-battery-negate-current-when-discharging.patch +revert-pci-acpi-fix-allocated-memory-release-on-error-in-pci_acpi_scan_root.patch -- 2.47.2