From: Lukas Czerner Date: Wed, 19 Jan 2022 13:02:09 +0000 (+0100) Subject: ext4: fix potential NULL pointer dereference in ext4_fill_super() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7c268d4ce2d3761f666a9950b029c8902bfab710;p=linux.git ext4: fix potential NULL pointer dereference in ext4_fill_super() By mistake we fail to return an error from ext4_fill_super() in case that ext4_alloc_sbi() fails to allocate a new sbi. Instead we just set the ret variable and allow the function to continue which will later lead to a NULL pointer dereference. Fix it by returning -ENOMEM in the case ext4_alloc_sbi() fails. Fixes: cebe85d570cf ("ext4: switch to the new mount api") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Lukas Czerner Link: https://lore.kernel.org/r/20220119130209.40112-1-lczerner@redhat.com Signed-off-by: Theodore Ts'o Cc: stable@kernel.org --- diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 57914acc54028..d1c4b04e72ab0 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5541,7 +5541,7 @@ static int ext4_fill_super(struct super_block *sb, struct fs_context *fc) sbi = ext4_alloc_sbi(sb); if (!sbi) - ret = -ENOMEM; + return -ENOMEM; fc->s_fs_info = sbi;