udev-node: stack directory must exist when adding device node symlink
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 31 Aug 2021 19:14:42 +0000 (04:14 +0900)
committerRaspbian forward porter <root@raspbian.org>
Fri, 15 Oct 2021 10:50:57 +0000 (11:50 +0100)
(cherry picked from commit 46070dbf26435ba0def099121f46a6253f3f19b6)

Gbp-Pq: Name udev-node-stack-directory-must-exist-when-adding-device-n.patch

src/udev/udev-node.c

index 7cc9ee3670e7746959e5077229db17b975da0c1a..4496a2bd9b770d64df6f7d93f571b5e41686b4b0 100644 (file)
@@ -161,12 +161,13 @@ static int link_find_prioritized(sd_device *dev, bool add, const char *stackdir,
 
         dir = opendir(stackdir);
         if (!dir) {
-                if (errno == ENOENT) {
-                        *ret = TAKE_PTR(target);
-                        return !!*ret;
-                }
+                if (add) /* The stack directory must exist. */
+                        return -errno;
+                if (errno != ENOENT)
+                        return -errno;
 
-                return -errno;
+                *ret = NULL;
+                return 0;
         }
 
         r = device_get_device_id(dev, &id);