udev-rules: use the right variable

We carefully prepare a copy of a local buffer to save in device cache
and then save the buffer there instead... This leads to abort in free()
on exit (also, copied is leaked).

Reproducer:
 # udevadm test /sys/block/sr0

Follow-up-for: a9559ebcbc

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2406118
This commit is contained in:
David Tardon
2025-12-05 15:17:13 +01:00
committed by Yu Watanabe
parent fdb9ad1a44
commit d23a7eb4c0

View File

@@ -3026,7 +3026,7 @@ static int udev_rule_apply_token_to_event(
if (!copied)
return log_oom();
r = device_cache_sysattr_value(dev, resolved, value, /* error = */ 0);
r = device_cache_sysattr_value(dev, resolved, copied, /* error = */ 0);
if (r < 0)
log_event_warning_errno(event, token, r, "Failed to cache sysfs attribute \"%s\", ignoring: %m", resolved);
else if (r > 0) {