Skip to content

Commit 7fff603

Browse files
khfengksacilotto
authored andcommitted
ACPI: sysfs: Prefer "compatible" modalias
BugLink: https://bugs.launchpad.net/bugs/1916056 commit 36af2d5 upstream. Commit 8765c5b ("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: systemd/systemd#18163 Suggested-by: Mika Westerberg <[email protected]> Fixes: 8765c5b ("ACPI / scan: Rework modalias creation when "compatible" is present") Signed-off-by: Kai-Heng Feng <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Cc: 4.1+ <[email protected]> # 4.1+ [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 2b6f17d commit 7fff603

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/acpi/device_sysfs.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,12 @@ int __acpi_device_uevent_modalias(struct acpi_device *adev,
251251
if (add_uevent_var(env, "MODALIAS="))
252252
return -ENOMEM;
253253

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);
268260
if (len < 0)
269261
return len;
270262

0 commit comments

Comments
 (0)