ext4: fix potential null pointer dereference in ext4_free_inode
authorNamjae Jeon <namjae.jeon@samsung.com>
Sat, 12 Jul 2014 20:11:42 +0000 (16:11 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 12 Jul 2014 20:11:42 +0000 (16:11 -0400)
Fix potential null pointer dereferencing problem caused by e43bb4e612
("ext4: decrement free clusters/inodes counters when block group declared bad")

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
fs/ext4/ialloc.c

index 0840bf321cdb59678ef69f17a746845bc0f11314..5b87fc36aab863d073de371bd8e9ae0159281917 100644 (file)
@@ -338,7 +338,7 @@ out:
                        fatal = err;
        } else {
                ext4_error(sb, "bit already cleared for inode %lu", ino);
-               if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
+               if (gdp && !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
                        int count;
                        count = ext4_free_inodes_count(sb, gdp);
                        percpu_counter_sub(&sbi->s_freeinodes_counter,