提交 bb3d132a 编写于 作者: D Dan Carpenter 提交者: Theodore Ts'o

ext4: fix potential NULL dereference in ext4_free_inodes_counts()

The ext4_get_group_desc() function returns NULL on error, and
ext4_free_inodes_count() function dereferences it without checking.
There is a check on the next line, but it's too late.
Reviewed-by: NJan Kara <jack@suse.cz>
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
上级 e93376c2
...@@ -508,10 +508,12 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, ...@@ -508,10 +508,12 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
for (i = 0; i < ngroups; i++) { for (i = 0; i < ngroups; i++) {
grp = (parent_group + i) % ngroups; grp = (parent_group + i) % ngroups;
desc = ext4_get_group_desc(sb, grp, NULL); desc = ext4_get_group_desc(sb, grp, NULL);
grp_free = ext4_free_inodes_count(sb, desc); if (desc) {
if (desc && grp_free && grp_free >= avefreei) { grp_free = ext4_free_inodes_count(sb, desc);
*group = grp; if (grp_free && grp_free >= avefreei) {
return 0; *group = grp;
return 0;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册