]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsns: fix ul_path_stat() error handling [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 9 Apr 2024 11:45:50 +0000 (13:45 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 9 Apr 2024 11:45:50 +0000 (13:45 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lsns.c

index 9d12ca205b443be0435b59311733b3f70a379e70..bc966dadb5724287f244daec298b708452e14ef1 100644 (file)
@@ -518,8 +518,9 @@ static void read_open_ns_inos(struct lsns *ls, struct path_cxt *pc)
                        continue;
 
                snprintf(path, sizeof(path), "fd/%ju", (uintmax_t) num);
-               ul_path_stat(pc, &st, 0, path);
-               if (st.st_dev == ls->nsfs_dev) {
+
+               if (ul_path_stat(pc, &st, 0, path) == 0
+                   && st.st_dev == ls->nsfs_dev) {
                        int fd = ul_path_open(pc, O_RDONLY, path);
                        if (fd >= 0) {
                                add_namespace_for_nsfd(ls, fd, st.st_ino);