From 47e151c0808f6738ab50010c880a7b643ec2b6d9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 6 Jun 2019 22:06:13 +0800 Subject: [PATCH] ext4: unsigned int compared against zero mainline inclusion from mainline-5.2-rc1 commit fbbbbd2f28aec991f3fbc248df211550fbdfd58c category: bugfix bugzilla: 16402 CVE: NA --------------------------- There are two cases where u32 variables n and err are being checked for less than zero error values, the checks is always false because the variables are not signed. Fix this by making the variables ints. Addresses-Coverity: ("Unsigned compared against 0") Fixes: 345c0dbf3a30 ("ext4: protect journal inode's blocks using block_validity") Signed-off-by: Colin Ian King Signed-off-by: Theodore Ts'o Signed-off-by: yangerkun Reviewed-by: zhangyi (F) Signed-off-by: Yang Yingliang --- fs/ext4/block_validity.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c index 9409b1e11a22..19cd6aecd9cf 100644 --- a/fs/ext4/block_validity.c +++ b/fs/ext4/block_validity.c @@ -142,7 +142,8 @@ static int ext4_protect_reserved_inode(struct super_block *sb, u32 ino) struct inode *inode; struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_map_blocks map; - u32 i = 0, err = 0, num, n; + u32 i = 0, num; + int err = 0, n; if ((ino < EXT4_ROOT_INO) || (ino > le32_to_cpu(sbi->s_es->s_inodes_count))) -- GitLab