Skip to content

Commit

Permalink
ext4: fix null pointer dereference on sbi
Browse files Browse the repository at this point in the history
In the case of a kzalloc failure when allocating sbi we end up
with a null pointer dereference on sbi when assigning sbi->s_daxdev.
Fix this by moving the assignment of sbi->s_daxdev to after the
null pointer check of sbi.

Detected by CoverityScan CID#1455379 ("Dereference before null check")

Fixes: 5e40559 ("ext4: perform dax_device lookup at mount")
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
Colin Ian King authored and djbw committed Sep 5, 2017
1 parent 9edcad5 commit aed9eb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3401,10 +3401,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
ext4_group_t first_not_zeroed;

sbi->s_daxdev = dax_dev;
if ((data && !orig_data) || !sbi)
goto out_free_base;

sbi->s_daxdev = dax_dev;
sbi->s_blockgroup_lock =
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
if (!sbi->s_blockgroup_lock)
Expand Down

0 comments on commit aed9eb1

Please sign in to comment.