ramfs: fix UAF in ramfs_create
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
72cb81c45a
commit
b3fc520a18
1 changed files with 5 additions and 4 deletions
|
|
@ -14,7 +14,7 @@ static u64 inode_ticker = 1;
|
|||
|
||||
int ramfs_create(u64 flags, fs_t **out)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
fs_t *fs = kalloc(sizeof(fs_t), ALLOC_KERN);
|
||||
if (!fs) {
|
||||
ret = -ENOMEM;
|
||||
|
|
@ -47,6 +47,7 @@ int ramfs_create(u64 flags, fs_t **out)
|
|||
root->inode = root_inode;
|
||||
|
||||
*out = fs;
|
||||
return 0;
|
||||
|
||||
out_root_inode:
|
||||
dirent_free(root);
|
||||
|
|
@ -66,7 +67,7 @@ static int alloc_inode(fs_t *fs, u64 mode, inode_t **out)
|
|||
return -ENOMEM;
|
||||
|
||||
ret->mode = mode;
|
||||
ret->ino_num = atomic_xadd(&inode_ticker, 1);
|
||||
ret->ino_num = atomic_xadd(&inode_ticker, 1);
|
||||
|
||||
*out = ret;
|
||||
return 0;
|
||||
|
|
@ -209,7 +210,7 @@ static dirent_t *mount(int flags, struct block_device *bdev)
|
|||
|
||||
static int umount(fs_t *fs)
|
||||
{
|
||||
return -EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
void ramfs_init()
|
||||
|
|
@ -234,6 +235,6 @@ void ramfs_init()
|
|||
|
||||
struct fs_type ramfs_type = {.name = "ramfs", .fs_mount = mount, .fs_umount = umount};
|
||||
|
||||
vfs_register(&ramfs_type);
|
||||
vfs_register(&ramfs_type);
|
||||
}
|
||||
DRIVER_ENTRY(ramfs_init);
|
||||
|
|
|
|||
Loading…
Reference in a new issue