From: Ting-Han Hou <ue081723@gmail.com>
To: stable@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Frederic MARIE-JOSEPH <fredericmariejoseph@protonmail.com>,
Wolfgang Walter <linux@stwm.de>,
Bob Anderson <kernel@ametros.net>,
Domenico Suppa <domenicosuppa@gmail.com>,
Thorsten Leemhuis <regressions@leemhuis.info>,
Sasha Levin <sashal@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-acpi@vger.kernel.org, regressions@lists.linux.dev,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Julien <julien82453@gmail.com>,
Paul Menzel <pmenzel@molgen.mpg.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 6.18.y 2/3] ACPI: scan: Avoid registering platform devices with resource overlaps
Date: Sat, 24 Oct 2026 18:57:09 +0800 [thread overview]
Message-ID: <20261024105710.593-3-ue081723@gmail.com> (raw)
In-Reply-To: <20261024105710.593-1-ue081723@gmail.com>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
commit f234fdaae1cad8c39265e7ca0a14633076ec7154 upstream.
If acpi_dev_get_resources() returns overlapping I/O or memory resources,
the subsequent registration of a platform device will fail with -EBUSY
due to a resource conflict. This is reported to happen on Acer Aspire
ES1-572 [1].
Avoid that by adjusting resources returned by acpi_dev_get_resources()
to eliminate partial overlaps between them.
This has not been regarded as necessary before because putting
overlapping resources into the _CRS of one device is really pointless,
but now that the issue has been reported to actually happen in the
field, it needs to be done.
Fixes: ab06eb920401 ("ACPI: scan: Register platform devices for fixed event buttons")
Fixes: 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
Reported-by: Julien <julien82453@gmail.com>
Tested-by: Julien <julien82453@gmail.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Closes: https://lore.kernel.org/linux-integrity/CAJOGg3z6LJPDsdPNBxajgy8_wQxfhYBRxe4EiurZf3kPU5A5Bw@mail.gmail.com/ [1]
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ rjw: Tweaked the new message ]
Link: https://patch.msgid.link/12955541.O9o76ZdvQC@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Ting-Han Hou <ue081723@gmail.com>
---
drivers/acpi/acpi_platform.c | 39 ++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 52c8d602f..abdd8893e 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -12,6 +12,7 @@
#include <linux/bits.h>
#include <linux/device.h>
#include <linux/err.h>
+#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/dma-mapping.h>
@@ -71,6 +72,36 @@ static struct notifier_block acpi_platform_notifier = {
.notifier_call = acpi_platform_device_remove_notify,
};
+static unsigned int acpi_platform_adjust_resources(struct acpi_device *adev,
+ struct resource *new_res,
+ struct resource *resources,
+ unsigned int count)
+{
+ unsigned int i;
+
+ if (!(new_res->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
+ return count;
+
+ for (i = 0; i < count; ) {
+ struct resource *res = &resources[i];
+
+ if (resource_type(new_res) != resource_type(res) ||
+ !resource_union(new_res, res, new_res)) {
+ i++;
+ continue;
+ }
+
+ dev_info(&adev->dev, "%pR expanded due to overlap\n", new_res);
+ /*
+ * Eliminate the previously processed resource that overlapped
+ * with the new one because it is not necessary any more.
+ */
+ memmove(res, res + 1, (--count - i) * sizeof(*res));
+ }
+
+ return count;
+}
+
static void acpi_platform_fill_resource(struct acpi_device *adev,
const struct resource *src, struct resource *dest)
{
@@ -151,10 +182,14 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
return ERR_PTR(-ENOMEM);
}
count = 0;
- list_for_each_entry(rentry, &resource_list, node)
+ list_for_each_entry(rentry, &resource_list, node) {
+ count = acpi_platform_adjust_resources(adev,
+ rentry->res,
+ resources,
+ count);
acpi_platform_fill_resource(adev, rentry->res,
&resources[count++]);
-
+ }
acpi_dev_free_resource_list(&resource_list);
}
}
--
2.53.0
next prev parent reply other threads:[~2026-10-24 10:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026102308-twisting-bazooka-12b5@gregkh>
2026-10-24 10:57 ` [PATCH 6.18.y 0/3] ACPI: scan: fix the fixed event power button since 6.18.57 Ting-Han Hou
2026-10-24 10:57 ` [PATCH 6.18.y 1/3] ACPI: scan: Register platform devices for fixed event buttons Ting-Han Hou
2026-10-24 10:57 ` Ting-Han Hou [this message]
2026-10-24 20:11 ` [PATCH 6.18.y 2/3] ACPI: scan: Avoid registering platform devices with resource overlaps Sasha Levin
2026-10-24 10:57 ` [PATCH 6.18.y 3/3] ACPI: scan: Do not combine resources that overlap completely Ting-Han Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261024105710.593-3-ue081723@gmail.com \
--to=ue081723@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=domenicosuppa@gmail.com \
--cc=fredericmariejoseph@protonmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=julien82453@gmail.com \
--cc=kernel@ametros.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux@stwm.de \
--cc=pmenzel@molgen.mpg.de \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=regressions@leemhuis.info \
--cc=regressions@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox