diff mbox series

[v2] ACPI / device_sysfs: Use OF_MODALIAS for "compatible" modalias

Message ID 20210119092327.310934-1-kai.heng.feng@canonical.com (mailing list archive)
State Superseded, archived
Headers show
Series [v2] ACPI / device_sysfs: Use OF_MODALIAS for "compatible" modalias | expand

Commit Message

Kai-Heng Feng Jan. 19, 2021, 9:23 a.m. UTC
Commit 8765c5ba1949 ("ACPI / scan: Rework modalias creation when
"compatible" is present") may create two "MODALIAS=" in uevent file if
conditions are met.

This breaks systemd-udevd, which assumes each "key" in uevent file is
unique. The internal implementation of systemd-udevd overwrites the
first MODALIAS with the second one, so its kmod rule doesn't load driver
for the first MODALIAS.

Right now it doesn't seem to have any user relies on the second
MODALIAS, so change it to OF_MODALIAS to workaround the issue.

Reference: https://github.com/systemd/systemd/pull/18163
Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v2:
 Add a comment to document why it's changed.

 drivers/acpi/device_sysfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 96869f1538b9..17483c40deeb 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -260,7 +260,11 @@  int __acpi_device_uevent_modalias(struct acpi_device *adev,
 	if (!adev->data.of_compatible)
 		return 0;
 
-	if (len > 0 && add_uevent_var(env, "MODALIAS="))
+	/* Two "MODALIAS=" breaks how systemd-udevd handles uevent file.
+	 * As userspace may not be able to handle duplicated keys, add prefix
+	 * "OF_" to avoid the key collision.
+	 */
+	if (len > 0 && add_uevent_var(env, "OF_MODALIAS="))
 		return -ENOMEM;
 
 	len = create_of_modalias(adev, &env->buf[env->buflen - 1],