ramfs: fix UAF in ramfs_create

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-05 01:54:32 +02:00
commit b3fc520a18

View file

@ -14,7 +14,7 @@ static u64 inode_ticker = 1;
int ramfs_create(u64 flags, fs_t **out) int ramfs_create(u64 flags, fs_t **out)
{ {
int ret = 0; int ret;
fs_t *fs = kalloc(sizeof(fs_t), ALLOC_KERN); fs_t *fs = kalloc(sizeof(fs_t), ALLOC_KERN);
if (!fs) { if (!fs) {
ret = -ENOMEM; ret = -ENOMEM;
@ -47,6 +47,7 @@ int ramfs_create(u64 flags, fs_t **out)
root->inode = root_inode; root->inode = root_inode;
*out = fs; *out = fs;
return 0;
out_root_inode: out_root_inode:
dirent_free(root); dirent_free(root);