diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-05-28 14:16:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-10 00:36:15 +0900 |
commit | 2c693b1d2fd1789a8b52f3644d41547b1ba9a26e (patch) | |
tree | 145a3893edbde6a3b87beb5b1699f7012784530e | |
parent | 978041f2a946a4616f7cdb60f6d453ffa83298c1 (diff) |
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>
-rw-r--r-- | fs/ext4/ialloc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 409c2ee7750..8900f8b2ad4 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -488,10 +488,12 @@ fallback_retry: for (i = 0; i < ngroups; i++) { grp = (parent_group + i) % ngroups; desc = ext4_get_group_desc(sb, grp, NULL); - grp_free = ext4_free_inodes_count(sb, desc); - if (desc && grp_free && grp_free >= avefreei) { - *group = grp; - return 0; + if (desc) { + grp_free = ext4_free_inodes_count(sb, desc); + if (grp_free && grp_free >= avefreei) { + *group = grp; + return 0; + } } } |