]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsns: don't call close(2) if unnecessary
authorMasatake YAMATO <yamato@redhat.com>
Thu, 19 Sep 2024 16:15:11 +0000 (01:15 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Thu, 19 Sep 2024 16:16:07 +0000 (01:16 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
sys-utils/lsns.c

index b2913152bc57cec2bf20ac2221f67af22b798fcc..8cf95ad24a4616053f4d3a94f6daff3458ca0429 100644 (file)
@@ -333,7 +333,7 @@ static int get_parent_ns_ino(int fd, enum lsns_type lsns_type, ino_t *pino, int
                *pino = st.st_ino;
        }
 
-       if (pfd == &my_fd)
+       if (pfd == &my_fd && *pfd >= 0)
                close(*pfd);
        return 0;
 }