mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: autofs: fix memory leak in autofs_fill_super()
@ 2026-09-03  8:10 Jeffin Philip
  2026-09-03 12:28 ` Ian Kent
  2026-09-04  7:48 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Jeffin Philip @ 2026-09-03  8:10 UTC (permalink / raw)
  To: raven
  Cc: bodonnel, brauner, autofs, linux-kernel, Jeffin Philip,
	syzbot+df1db6e034b3953e19f5, stable

In autofs_fill_super(), we create a new inode using
autofs_new_ino(), however, if we fail to create root_inode,
(that is, root_inode failure path), we return -ENOMEM without
freeing the new inode(ino) that we created causing a memory leak.
Fix this by adding autofs_free_ino() to free the inode we created
in root_inode failure path before returning ENOMEM.

Reported-by: syzbot+df1db6e034b3953e19f5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=df1db6e034b3953e19f5
Fixes: 66917f85db60 ("autofs: add: new_inode check in autofs_fill_super()")
Cc: stable@vger.kernel.org
Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
---
 fs/autofs/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index c1e210cec436..6b15a3717ba7 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -323,8 +323,10 @@ static int autofs_fill_super(struct super_block *s, struct fs_context *fc)
 		return -ENOMEM;
 
 	root_inode = autofs_get_inode(s, S_IFDIR | 0755);
-	if (!root_inode)
+	if (!root_inode) {
+		autofs_free_ino(ino);
 		return -ENOMEM;
+	}
 
 	root_inode->i_uid = ctx->uid;
 	root_inode->i_gid = ctx->gid;
-- 
2.55.0


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

* Re: [PATCH] fs: autofs: fix memory leak in autofs_fill_super()
  2026-09-03  8:10 [PATCH] fs: autofs: fix memory leak in autofs_fill_super() Jeffin Philip
@ 2026-09-03 12:28 ` Ian Kent
  2026-09-04  7:48 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Kent @ 2026-09-03 12:28 UTC (permalink / raw)
  To: Jeffin Philip
  Cc: bodonnel, brauner, autofs, linux-kernel,
	syzbot+df1db6e034b3953e19f5, stable

On 3/9/26 16:10, Jeffin Philip wrote:
> In autofs_fill_super(), we create a new inode using
> autofs_new_ino(), however, if we fail to create root_inode,
> (that is, root_inode failure path), we return -ENOMEM without
> freeing the new inode(ino) that we created causing a memory leak.
> Fix this by adding autofs_free_ino() to free the inode we created
> in root_inode failure path before returning ENOMEM.
>
> Reported-by: syzbot+df1db6e034b3953e19f5@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=df1db6e034b3953e19f5
> Fixes: 66917f85db60 ("autofs: add: new_inode check in autofs_fill_super()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
> ---
>   fs/autofs/inode.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
> index c1e210cec436..6b15a3717ba7 100644
> --- a/fs/autofs/inode.c
> +++ b/fs/autofs/inode.c
> @@ -323,8 +323,10 @@ static int autofs_fill_super(struct super_block *s, struct fs_context *fc)
>   		return -ENOMEM;
>   
>   	root_inode = autofs_get_inode(s, S_IFDIR | 0755);
> -	if (!root_inode)
> +	if (!root_inode) {
> +		autofs_free_ino(ino);
>   		return -ENOMEM;
> +	}
>   
>   	root_inode->i_uid = ctx->uid;
>   	root_inode->i_gid = ctx->gid;


Thanks Jeffin, this looks better.


Signed-off-by: Ian Kent <raven@themaw.net>

Christian, can you take this one please, ;)


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

* Re: [PATCH] fs: autofs: fix memory leak in autofs_fill_super()
  2026-09-03  8:10 [PATCH] fs: autofs: fix memory leak in autofs_fill_super() Jeffin Philip
  2026-09-03 12:28 ` Ian Kent
@ 2026-09-04  7:48 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-09-04  7:48 UTC (permalink / raw)
  To: raven, Jeffin Philip
  Cc: Christian Brauner, bodonnel, autofs, linux-kernel,
	syzbot+df1db6e034b3953e19f5, stable

On Thu, 03 Sep 2026 13:40:48 +0530, Jeffin Philip wrote:
> In autofs_fill_super(), we create a new inode using
> autofs_new_ino(), however, if we fail to create root_inode,
> (that is, root_inode failure path), we return -ENOMEM without
> freeing the new inode(ino) that we created causing a memory leak.
> Fix this by adding autofs_free_ino() to free the inode we created
> in root_inode failure path before returning ENOMEM.
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] fs: autofs: fix memory leak in autofs_fill_super()
      https://git.kernel.org/vfs/vfs/c/5ab54837fce0

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

end of thread, other threads:[~2026-09-04  7:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-03  8:10 [PATCH] fs: autofs: fix memory leak in autofs_fill_super() Jeffin Philip
2026-09-03 12:28 ` Ian Kent
2026-09-04  7:48 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®