fat_close_impl and ext2_close_impl unconditionally called kfree() on
the node passed to vfs_close(). When a directory fd pointed to a
filesystem mount root (a static variable like g_fat_root or
g_ext2_root), this kfree corrupted the heap (bad magic 0x0).
diskfs_close_impl already had the guard pattern (dn == &g_root).
Apply the same guard to fat and ext2 close handlers.
static void ext2_close_impl(fs_node_t* node) {
if (!node) return;
struct ext2_node* en = (struct ext2_node*)node;
+ if (en == &g_ext2_root) return;
kfree(en);
}
static void fat_close_impl(fs_node_t* node) {
if (!node) return;
struct fat_node* fn = (struct fat_node*)node;
+ if (fn == &g_fat_root) return;
kfree(fn);
}