diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-06-02 16:29:59 +0900 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-09 18:48:18 +0200 |
commit | 93cf1abc60b774eb5c19e327a2079f67e80011df (patch) | |
tree | 750f74da60db7f00db0d5701dfbe24c3ac26aacc | |
parent | 688b311f5c6c0b20a3811f6a135bf87e11f36502 (diff) | |
download | systemd-93cf1abc60b774eb5c19e327a2079f67e80011df.tar.gz |
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.
```
(cherry picked from commit 2255e8adee37c490bf8cf2daab791b6f746bb0a0)
-rw-r--r-- | src/libsystemd/sd-device/device-private.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 7a7204b145..46ce0229c5 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -629,6 +629,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); @@ -642,9 +643,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; |