From: Yu Watanabe Date: Wed, 2 Jun 2021 07:29:59 +0000 (+0900) Subject: sd-device: do not use ::subsystem member directly X-Git-Tag: v249-rc1~108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2255e8adee37c490bf8cf2daab791b6f746bb0a0;p=thirdparty%2Fsystemd.git sd-device: do not use ::subsystem member directly The value is set dynamically when sd_device_get_subsystem() is called first time. Fixes the following issue: ``` $ build/udevadm test /sys/class/block/dm-1 ... Assertion '_subsystem' failed at src/libsystemd/sd-device/sd-device.c:767, function device_set_subsystem(). Aborting. Program received signal SIGABRT, Aborted. ``` --- diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 09ef87f84cc..3ede43f3775 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -743,6 +743,7 @@ int device_rename(sd_device *device, const char *name) { int device_shallow_clone(sd_device *old_device, sd_device **new_device) { _cleanup_(sd_device_unrefp) sd_device *ret = NULL; + const char *subsystem; int r; assert(old_device); @@ -756,9 +757,12 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) { if (r < 0) return r; - r = device_set_subsystem(ret, old_device->subsystem); - if (r < 0) - return r; + if (sd_device_get_subsystem(old_device, &subsystem) >= 0) { + r = device_set_subsystem(ret, subsystem); + if (r < 0) + return r; + } else + ret->subsystem_set = true; ret->devnum = old_device->devnum;