* [PATCH] fs/ntfs3: Fix leaked mount_options if fill_super failed
@ 2022-11-22 9:25 Chen Zhongjin
2022-12-26 15:41 ` Konstantin Komarov
0 siblings, 1 reply; 2+ messages in thread
From: Chen Zhongjin @ 2022-11-22 9:25 UTC (permalink / raw)
To: ntfs3, linux-kernel; +Cc: chenzhongjin, kari.argillander, almaz.alexandrovich
'9b75450d6c58 ("fs/ntfs3: Fix memory leak if fill_super failed")'
Previous patch fixed leaked sbi when fill_super failed but forgot to put
mount_options and left it leaked as kmemleak reported:
unreferenced object 0xffff888107c353c0 (size 32):
backtrace:
[<00000000cf2c8c32>] kmalloc_trace+0x27/0x110
[<000000000184a864>] ntfs_init_fs_context+0x4c/0x540 [ntfs3]
[<000000008ded85aa>] alloc_fs_context+0x50e/0x940
[<00000000c225e601>] path_mount+0x747/0x1930
[<000000007bf15a5f>] do_mount+0xf3/0x110
...
unreferenced object 0xffff888101fdc2d0 (size 8):
backtrace:
[<00000000d0cba437>] __kmalloc_node_track_caller+0x4c/0x1c0
[<00000000923513f8>] kmemdup_nul+0x37/0xb0
[<000000007a9b98ed>] vfs_parse_fs_string+0xc5/0x150
[<00000000afbd0594>] generic_parse_monolithic+0x140/0x1c0
[<00000000e97e814e>] path_mount+0xf09/0x1930
[<000000007bf15a5f>] do_mount+0xf3/0x110
...
Fixes: 610f8f5a7baf ("fs/ntfs3: Use new api for mounting")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
---
fs/ntfs3/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 47012c9bf505..c0e45f170701 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1281,6 +1281,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
* Free resources here.
* ntfs_fs_free will be called with fc->s_fs_info = NULL
*/
+ put_mount_options(sbi->options);
put_ntfs(sbi);
sb->s_fs_info = NULL;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/ntfs3: Fix leaked mount_options if fill_super failed
2022-11-22 9:25 [PATCH] fs/ntfs3: Fix leaked mount_options if fill_super failed Chen Zhongjin
@ 2022-12-26 15:41 ` Konstantin Komarov
0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2022-12-26 15:41 UTC (permalink / raw)
To: Chen Zhongjin, ntfs3, linux-kernel; +Cc: kari.argillander
On 22.11.2022 13:25, Chen Zhongjin wrote:
> '9b75450d6c58 ("fs/ntfs3: Fix memory leak if fill_super failed")'
> Previous patch fixed leaked sbi when fill_super failed but forgot to put
> mount_options and left it leaked as kmemleak reported:
>
> unreferenced object 0xffff888107c353c0 (size 32):
> backtrace:
> [<00000000cf2c8c32>] kmalloc_trace+0x27/0x110
> [<000000000184a864>] ntfs_init_fs_context+0x4c/0x540 [ntfs3]
> [<000000008ded85aa>] alloc_fs_context+0x50e/0x940
> [<00000000c225e601>] path_mount+0x747/0x1930
> [<000000007bf15a5f>] do_mount+0xf3/0x110
> ...
> unreferenced object 0xffff888101fdc2d0 (size 8):
> backtrace:
> [<00000000d0cba437>] __kmalloc_node_track_caller+0x4c/0x1c0
> [<00000000923513f8>] kmemdup_nul+0x37/0xb0
> [<000000007a9b98ed>] vfs_parse_fs_string+0xc5/0x150
> [<00000000afbd0594>] generic_parse_monolithic+0x140/0x1c0
> [<00000000e97e814e>] path_mount+0xf09/0x1930
> [<000000007bf15a5f>] do_mount+0xf3/0x110
> ...
>
> Fixes: 610f8f5a7baf ("fs/ntfs3: Use new api for mounting")
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
> fs/ntfs3/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 47012c9bf505..c0e45f170701 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -1281,6 +1281,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
> * Free resources here.
> * ntfs_fs_free will be called with fc->s_fs_info = NULL
> */
> + put_mount_options(sbi->options);
> put_ntfs(sbi);
> sb->s_fs_info = NULL;
>
Thanks for work, this bug has already been fixed:
https://lore.kernel.org/ntfs3/20220823103205.1380235-1-syoshida@redhat.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-26 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 9:25 [PATCH] fs/ntfs3: Fix leaked mount_options if fill_super failed Chen Zhongjin
2022-12-26 15:41 ` Konstantin Komarov
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).