From: Yu Watanabe Date: Sun, 18 Sep 2022 00:03:05 +0000 (+0900) Subject: sd-device: refuse block device without subsystem X-Git-Tag: v252-rc1~154 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23d3dfc369fb8ccb8c19c6b752923c267b89063b;p=thirdparty%2Fsystemd.git sd-device: refuse block device without subsystem Previously, even if sd_device_get_subsystem() returns -ENOENT for block device, we accepted that. This makes the check slightly stricter. --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 91af4a27ed8..13328ffd836 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -281,7 +281,7 @@ _public_ int sd_device_new_from_syspath(sd_device **ret, const char *syspath) { int device_new_from_mode_and_devnum(sd_device **ret, mode_t mode, dev_t devnum) { _cleanup_(sd_device_unrefp) sd_device *dev = NULL; _cleanup_free_ char *syspath = NULL; - const char *t, *subsystem; + const char *t, *subsystem = NULL; dev_t n; int r; @@ -315,7 +315,7 @@ int device_new_from_mode_and_devnum(sd_device **ret, mode_t mode, dev_t devnum) r = sd_device_get_subsystem(dev, &subsystem); if (r < 0 && r != -ENOENT) return r; - if (r >= 0 && streq(subsystem, "block") != !!S_ISBLK(mode)) + if (streq_ptr(subsystem, "block") != !!S_ISBLK(mode)) return -ENXIO; *ret = TAKE_PTR(dev);