diff --git a/src/kernel/core/module.c b/src/kernel/core/module.c index 10e0869961..f6cf239ce9 100644 --- a/src/kernel/core/module.c +++ b/src/kernel/core/module.c @@ -431,8 +431,10 @@ static int recurse_directory(const char *path, const char *match) return -1; dirent = kmalloc(bufferSize); - if (!dirent) + if (!dirent) { + sys_close(dir); return -1; + } /* loop until we have a match or we run out of entries */ while (res <= 0) {