Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: sysfs: Prefer "compatible" modalias

Commit 8765c5ba1949 ("ACPI / scan: Rework modalias creation when
"compatible" is present") may create two "MODALIAS=" in one uevent
file if specific conditions are met.

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

So if both the ACPI modalias and the OF modalias are present, use the
latter to ensure that there will be only one MODALIAS.

Link: https://github.com/systemd/systemd/pull/18163
Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes: 8765c5ba1949 ("ACPI / scan: Rework modalias creation when "compatible" is present")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: 4.1+ <stable@vger.kernel.org> # 4.1+
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Kai-Heng Feng and committed by
Rafael J. Wysocki
36af2d5c 6ee1d745

+6 -14
+6 -14
drivers/acpi/device_sysfs.c
··· 251 251 if (add_uevent_var(env, "MODALIAS=")) 252 252 return -ENOMEM; 253 253 254 - len = create_pnp_modalias(adev, &env->buf[env->buflen - 1], 255 - sizeof(env->buf) - env->buflen); 256 - if (len < 0) 257 - return len; 258 - 259 - env->buflen += len; 260 - if (!adev->data.of_compatible) 261 - return 0; 262 - 263 - if (len > 0 && add_uevent_var(env, "MODALIAS=")) 264 - return -ENOMEM; 265 - 266 - len = create_of_modalias(adev, &env->buf[env->buflen - 1], 267 - sizeof(env->buf) - env->buflen); 254 + if (adev->data.of_compatible) 255 + len = create_of_modalias(adev, &env->buf[env->buflen - 1], 256 + sizeof(env->buf) - env->buflen); 257 + else 258 + len = create_pnp_modalias(adev, &env->buf[env->buflen - 1], 259 + sizeof(env->buf) - env->buflen); 268 260 if (len < 0) 269 261 return len; 270 262