dx_lookup() uses errcode_t return values. As such anything non-zero is an error, not values less than zero. Fix the error checking to avoid crashes on corrupted filesystems. Signed-off-by: Jan Kara <jack@xxxxxxx> --- lib/ext2fs/link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c index 6f523aee718c..7b5bb022117c 100644 --- a/lib/ext2fs/link.c +++ b/lib/ext2fs/link.c @@ -571,7 +571,7 @@ static errcode_t dx_link(ext2_filsys fs, ext2_ino_t dir, dx_info.namelen = strlen(name); again: retval = dx_lookup(fs, dir, diri, &dx_info); - if (retval < 0) + if (retval) goto free_buf; retval = add_dirent_to_buf(fs, -- 2.16.4