add patch enable-journal-checksum-when-metadata-checksum-feature-enabled
[ext4-patch-queue.git] / fix-oops-when-loading-block-bitmap-failed
blob01334cc9c1d148e13e2d3e33acefe92d25b19c6d
1 ext4: fix oops when loading block bitmap failed
3 From: Jan Kara <jack@suse.cz>
5 When we fail to load block bitmap in __ext4_new_inode() we will
6 dereference NULL pointer in ext4_journal_get_write_access(). So check
7 for error from ext4_read_block_bitmap().
9 Coverity-id: 989065
10 Cc: stable@vger.kernel.org
11 Signed-off-by: Jan Kara <jack@suse.cz>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 ---
14  fs/ext4/ialloc.c | 4 ++++
15  1 file changed, 4 insertions(+)
17 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
18 index 8012a5daf401..ac644c31ca67 100644
19 --- a/fs/ext4/ialloc.c
20 +++ b/fs/ext4/ialloc.c
21 @@ -887,6 +887,10 @@ got:
22                 struct buffer_head *block_bitmap_bh;
24                 block_bitmap_bh = ext4_read_block_bitmap(sb, group);
25 +               if (!block_bitmap_bh) {
26 +                       err = -EIO;
27 +                       goto out;
28 +               }
29                 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access");
30                 err = ext4_journal_get_write_access(handle, block_bitmap_bh);
31                 if (err) {
32 -- 
33 1.8.1.4
36 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
37 the body of a message to majordomo@vger.kernel.org
38 More majordomo info at  http://vger.kernel.org/majordomo-info.html