aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2023-11-06 11:40:27 +0100
committerKarel Zak <kzak@redhat.com>2023-11-06 11:40:27 +0100
commitc8448495049b22e6ee30c84c377e61f65d886ca3 (patch)
treec03205ffbb7abd08055afb6501f8d457aa718bc8 /libmount/src
parent5f3359c5c9dab9d5791d05a646b9c04c19eeb80e (diff)
downloadutil-linux-c8448495049b22e6ee30c84c377e61f65d886ca3.tar.gz
libmount: fix possible NULL dereference [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/tab.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 5c2d5c868b..972566467b 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -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) {