]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix possible NULL dereference [coverity scan]
authorKarel Zak <kzak@redhat.com>
Mon, 6 Nov 2023 10:40:27 +0000 (11:40 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 6 Nov 2023 10:40:27 +0000 (11:40 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab.c

index 5c2d5c868b84932860ea87fcd012ed0770cd36ed..972566467bd82d2e28acb067a3c57a52863bd5ad 100644 (file)
@@ -660,7 +660,7 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
 {
        struct libmnt_fs *fs, *chfs = NULL;
        int parent_id, lastchld_id = 0, chld_id = 0;
-       int direction = mnt_iter_get_direction(itr);
+       int direction;
 
        if (!tb || !itr || !parent || !is_mountinfo(tb))
                return -EINVAL;
@@ -668,6 +668,7 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
        DBG(TAB, ul_debugobj(tb, "lookup next child of '%s'",
                                mnt_fs_get_target(parent)));
        parent_id = mnt_fs_get_id(parent);
+       direction = mnt_iter_get_direction(itr);
 
        /* get ID of the previously returned child */
        if (itr->head && itr->p != itr->head) {