From 2a6d3b8baa37a2e7d6a1e3f5dd211b2b8bc53661 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Fri, 28 Apr 2023 22:30:09 -0700 Subject: [PATCH] sys/vfs/hammer2: Fix memory leak for second PFS mount and after When mounting, hmp and its ->devvpl are initialized only if it's the first PFS mount of that hmp. For the second PFS mount and after, malloc'd memory in a devvpl list (64 bytes per device per PFS) has been leaked. Found on FreeBSD on kldunload. -- Warning: memory type hammer2_mount leaked memory on destroy (1 allocations, 64 bytes leaked). --- sys/vfs/hammer2/hammer2_vfsops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/vfs/hammer2/hammer2_vfsops.c b/sys/vfs/hammer2/hammer2_vfsops.c index f705f807d2..a728abdbd3 100644 --- a/sys/vfs/hammer2/hammer2_vfsops.c +++ b/sys/vfs/hammer2/hammer2_vfsops.c @@ -1378,6 +1378,8 @@ next_hmp: } } } else { + /* hmp->devvp_list is already constructed. */ + hammer2_cleanup_devvp(&devvpl); spmp = hmp->spmp; if (info.hflags & HMNT2_DEVFLAGS) { kprintf("hammer2_mount: Warning: mount flags pertaining " -- 2.11.4.GIT