Skip to content

Commit be590d7

Browse files
Dan Carpenterpanos
authored andcommitted
ext4: fix potential NULL dereference in ext4_free_inodes_counts()
commit bb3d132a24cd8bf5e7773b2d9f9baa58b07a7dae upstream. 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: Jan Kara <jack@suse.cz> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0f68360 commit be590d7

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

fs/ext4/ialloc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,12 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
488488
for (i = 0; i < ngroups; i++) {
489489
grp = (parent_group + i) % ngroups;
490490
desc = ext4_get_group_desc(sb, grp, NULL);
491-
grp_free = ext4_free_inodes_count(sb, desc);
492-
if (desc && grp_free && grp_free >= avefreei) {
493-
*group = grp;
494-
return 0;
491+
if (desc) {
492+
grp_free = ext4_free_inodes_count(sb, desc);
493+
if (grp_free && grp_free >= avefreei) {
494+
*group = grp;
495+
return 0;
496+
}
495497
}
496498
}
497499

0 commit comments

Comments
 (0)