summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ialloc.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-05-28 20:16:57 +0200
committerTheodore Ts'o <tytso@mit.edu>2012-05-28 20:16:57 +0200
commitbb3d132a24cd8bf5e7773b2d9f9baa58b07a7dae (patch)
treec88fbbdb6464bfa35c047b207dd6097f3b447375 /fs/ext4/ialloc.c
parentext4/jbd2: add metadata checksumming to the list of supported features (diff)
downloadlinux-bb3d132a24cd8bf5e7773b2d9f9baa58b07a7dae.tar.xz
linux-bb3d132a24cd8bf5e7773b2d9f9baa58b07a7dae.zip
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: Jan Kara <jack@suse.cz> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: stable@kernel.org
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r--fs/ext4/ialloc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index a044a9b77491..ea32d7e1d6e3 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -508,10 +508,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;
+ }
}
}