Skip to content

Commit 96bc858

Browse files
committed
libmount: previously assumed null pointer [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
1 parent 84ce576 commit 96bc858

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libmount/src/tab.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
506506

507507
if (path == NULL && src == NULL)
508508
return fs; /* source is "none" */
509-
if (p && strcmp(p, path) == 0)
509+
if (path && p && strcmp(p, path) == 0)
510510
return fs;
511511
if (!p && src)
512512
ntags++; /* mnt_fs_get_srcpath() returs nothing, it's TAG */
@@ -845,7 +845,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
845845

846846
tgt = mnt_fs_get_target(fstab_fs);
847847

848-
if (tgt || src || root) {
848+
if (tgt && src && root) {
849849
struct libmnt_iter itr;
850850
struct libmnt_fs *fs;
851851

@@ -856,8 +856,8 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
856856
*t = mnt_fs_get_target(fs),
857857
*r = mnt_fs_get_root(fs);
858858

859-
if (s && t && r && !strcmp(t, tgt) &&
860-
!strcmp(s, src) && !strcmp(r, root))
859+
if (t && s && r &&
860+
!strcmp(t, tgt) && !strcmp(s, src) && !strcmp(r, root))
861861
break;
862862
}
863863
if (fs)

0 commit comments

Comments
 (0)