From 26bc325d72632bf7995223910fa83c8f40af08c8 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 28 Feb 2024 21:24:17 -0500 Subject: kernel: vfs: Do not leak memory Signed-off-by: Ian Moffett --- sys/kern/vfs_subr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/kern/vfs_subr.c') diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 04b644e..27f10ee 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -77,11 +77,13 @@ vfs_hash_path(const char *path) return 0; } - do { + while (name != NULL) { name = vfs_get_fname_at(path, i++); - if (name != NULL) + if (name != NULL) { hash += vfs_hash(name); - } while (name != NULL); + dynfree(name); + } + } return hash; } @@ -185,6 +187,7 @@ vfs_mount(struct mount **mp_out, const char *path, int mnt_flags) cache_status = vfs_cache_mp(mp, path); if (cache_status != 0) { + dynfree(mp); return cache_status; } -- cgit v1.2.3