summaryrefslogtreecommitdiff
path: root/libudev/libudev-util-private.c
diff options
context:
space:
mode:
Diffstat (limited to 'libudev/libudev-util-private.c')
-rw-r--r--libudev/libudev-util-private.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c
index 042b711928..fe8f29b3a8 100644
--- a/libudev/libudev-util-private.c
+++ b/libudev/libudev-util-private.c
@@ -34,11 +34,12 @@ int util_create_path(struct udev *udev, const char *path)
util_strscpy(p, sizeof(p), path);
pos = strrchr(p, '/');
- if (pos == p || pos == NULL)
+ if (pos == NULL)
return 0;
-
- while (pos[-1] == '/')
+ while (pos != p && pos[-1] == '/')
pos--;
+ if (pos == p)
+ return 0;
pos[0] = '\0';
dbg(udev, "stat '%s'\n", p);