linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix bio memleak when committing super block
@ 2025-06-07  6:41 Sheng Yong
  2025-06-07 11:24 ` Chao Yu via Linux-f2fs-devel
  2025-06-24  0:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
  0 siblings, 2 replies; 3+ messages in thread
From: Sheng Yong @ 2025-06-07  6:41 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Sheng Yong, linux-kernel, linux-f2fs-devel

From: Sheng Yong <shengyong1@xiaomi.com>

When committing new super block, bio is allocated but not freed, and
kmemleak complains:

  unreferenced object 0xffff88801d185600 (size 192):
    comm "kworker/3:2", pid 128, jiffies 4298624992
    hex dump (first 32 bytes):
      00 00 00 00 00 00 00 00 80 67 c3 00 81 88 ff ff  .........g......
      01 08 06 00 00 00 00 00 00 00 00 00 01 00 00 00  ................
    backtrace (crc 650ecdb1):
      kmem_cache_alloc_noprof+0x3a9/0x460
      mempool_alloc_noprof+0x12f/0x310
      bio_alloc_bioset+0x1e2/0x7e0
      __f2fs_commit_super+0xe0/0x370
      f2fs_commit_super+0x4ed/0x8c0
      f2fs_record_error_work+0xc7/0x190
      process_one_work+0x7db/0x1970
      worker_thread+0x518/0xea0
      kthread+0x359/0x690
      ret_from_fork+0x34/0x70
      ret_from_fork_asm+0x1a/0x30

The issue can be reproduced by:

  mount /dev/vda /mnt
  i=0
  while :; do
      echo '[h]abc' > /sys/fs/f2fs/vda/extension_list
      echo '[h]!abc' > /sys/fs/f2fs/vda/extension_list
      echo scan > /sys/kernel/debug/kmemleak
      dmesg | grep "new suspected memory leaks"
      [ $? -eq 0 ] && break
      i=$((i + 1))
      echo "$i"
  done
  umount /mnt

Fixes: 5bcde4557862 ("f2fs: get rid of buffer_head use")
Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
---
 fs/f2fs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ebda6834ac2c..57adeff5ef25 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3701,6 +3701,7 @@ static int __f2fs_commit_super(struct f2fs_sb_info *sbi, struct folio *folio,
 		f2fs_bug_on(sbi, 1);
 
 	ret = submit_bio_wait(bio);
+	bio_put(bio);
 	folio_end_writeback(folio);
 
 	return ret;
-- 
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: fix bio memleak when committing super block
  2025-06-07  6:41 [f2fs-dev] [PATCH] f2fs: fix bio memleak when committing super block Sheng Yong
@ 2025-06-07 11:24 ` Chao Yu via Linux-f2fs-devel
  2025-06-24  0:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-06-07 11:24 UTC (permalink / raw)
  To: Sheng Yong, jaegeuk; +Cc: Sheng Yong, linux-kernel, linux-f2fs-devel

On 2025/6/7 14:41, Sheng Yong wrote:
> From: Sheng Yong <shengyong1@xiaomi.com>
> 
> When committing new super block, bio is allocated but not freed, and
> kmemleak complains:
> 
>    unreferenced object 0xffff88801d185600 (size 192):
>      comm "kworker/3:2", pid 128, jiffies 4298624992
>      hex dump (first 32 bytes):
>        00 00 00 00 00 00 00 00 80 67 c3 00 81 88 ff ff  .........g......
>        01 08 06 00 00 00 00 00 00 00 00 00 01 00 00 00  ................
>      backtrace (crc 650ecdb1):
>        kmem_cache_alloc_noprof+0x3a9/0x460
>        mempool_alloc_noprof+0x12f/0x310
>        bio_alloc_bioset+0x1e2/0x7e0
>        __f2fs_commit_super+0xe0/0x370
>        f2fs_commit_super+0x4ed/0x8c0
>        f2fs_record_error_work+0xc7/0x190
>        process_one_work+0x7db/0x1970
>        worker_thread+0x518/0xea0
>        kthread+0x359/0x690
>        ret_from_fork+0x34/0x70
>        ret_from_fork_asm+0x1a/0x30
> 
> The issue can be reproduced by:
> 
>    mount /dev/vda /mnt
>    i=0
>    while :; do
>        echo '[h]abc' > /sys/fs/f2fs/vda/extension_list
>        echo '[h]!abc' > /sys/fs/f2fs/vda/extension_list
>        echo scan > /sys/kernel/debug/kmemleak
>        dmesg | grep "new suspected memory leaks"
>        [ $? -eq 0 ] && break
>        i=$((i + 1))
>        echo "$i"
>    done
>    umount /mnt
> 
> Fixes: 5bcde4557862 ("f2fs: get rid of buffer_head use")
> Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: fix bio memleak when committing super block
  2025-06-07  6:41 [f2fs-dev] [PATCH] f2fs: fix bio memleak when committing super block Sheng Yong
  2025-06-07 11:24 ` Chao Yu via Linux-f2fs-devel
@ 2025-06-24  0:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2025-06-24  0:40 UTC (permalink / raw)
  To: Sheng Yong; +Cc: jaegeuk, shengyong1, linux-kernel, linux-f2fs-devel

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Sat,  7 Jun 2025 14:41:16 +0800 you wrote:
> From: Sheng Yong <shengyong1@xiaomi.com>
> 
> When committing new super block, bio is allocated but not freed, and
> kmemleak complains:
> 
>   unreferenced object 0xffff88801d185600 (size 192):
>     comm "kworker/3:2", pid 128, jiffies 4298624992
>     hex dump (first 32 bytes):
>       00 00 00 00 00 00 00 00 80 67 c3 00 81 88 ff ff  .........g......
>       01 08 06 00 00 00 00 00 00 00 00 00 01 00 00 00  ................
>     backtrace (crc 650ecdb1):
>       kmem_cache_alloc_noprof+0x3a9/0x460
>       mempool_alloc_noprof+0x12f/0x310
>       bio_alloc_bioset+0x1e2/0x7e0
>       __f2fs_commit_super+0xe0/0x370
>       f2fs_commit_super+0x4ed/0x8c0
>       f2fs_record_error_work+0xc7/0x190
>       process_one_work+0x7db/0x1970
>       worker_thread+0x518/0xea0
>       kthread+0x359/0x690
>       ret_from_fork+0x34/0x70
>       ret_from_fork_asm+0x1a/0x30
> 
> [...]

Here is the summary with links:
  - [f2fs-dev] f2fs: fix bio memleak when committing super block
    https://git.kernel.org/jaegeuk/f2fs/c/554d9b7242a7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2025-06-24  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-07  6:41 [f2fs-dev] [PATCH] f2fs: fix bio memleak when committing super block Sheng Yong
2025-06-07 11:24 ` Chao Yu via Linux-f2fs-devel
2025-06-24  0:40 ` patchwork-bot+f2fs--- via Linux-f2fs-devel

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).