linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix potential NULL pointer dereference in ext4_fill_super()
@ 2022-01-19 13:02 Lukas Czerner
  2022-01-29  3:55 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Czerner @ 2022-01-19 13:02 UTC (permalink / raw)
  To: linux-ext4, tytso; +Cc: kernel test robot, Dan Carpenter

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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index db9fe4843529..6023ebb5b19d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5543,7 +5543,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;
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: fix potential NULL pointer dereference in ext4_fill_super()
  2022-01-19 13:02 [PATCH] ext4: fix potential NULL pointer dereference in ext4_fill_super() Lukas Czerner
@ 2022-01-29  3:55 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2022-01-29  3:55 UTC (permalink / raw)
  To: linux-ext4, Lukas Czerner
  Cc: Theodore Ts'o, Dan Carpenter, kernel test robot

On Wed, 19 Jan 2022 14:02:09 +0100, Lukas Czerner wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] ext4: fix potential NULL pointer dereference in ext4_fill_super()
      commit: 7c6bb3d664aa05bf4366fd79a13921acfca28a6d

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-29  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 13:02 [PATCH] ext4: fix potential NULL pointer dereference in ext4_fill_super() Lukas Czerner
2022-01-29  3:55 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).