ramfs: fix dirent refcount bug
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
eb41b17fea
commit
1fc17e6d6e
1 changed files with 1 additions and 3 deletions
|
|
@ -44,13 +44,13 @@ int ramfs_create(u64 flags, fs_t **out)
|
||||||
fs->root_dirent = root;
|
fs->root_dirent = root;
|
||||||
root->type = S_IFDIR;
|
root->type = S_IFDIR;
|
||||||
root->fs = fs;
|
root->fs = fs;
|
||||||
inode_inc_ref(root_inode);
|
|
||||||
root->inode = root_inode;
|
root->inode = root_inode;
|
||||||
|
|
||||||
*out = fs;
|
*out = fs;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_root_inode:
|
out_root_inode:
|
||||||
|
inode_dec_ref_lock(root_inode);
|
||||||
dirent_free(root);
|
dirent_free(root);
|
||||||
out_root:
|
out_root:
|
||||||
kfree(fs);
|
kfree(fs);
|
||||||
|
|
@ -153,12 +153,10 @@ static int link(dirent_t *in, inode_t *to, const char *name, dirent_t **out)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
inode_inc_ref(to);
|
|
||||||
new->inode = to;
|
new->inode = to;
|
||||||
new->fs = in->fs;
|
new->fs = in->fs;
|
||||||
|
|
||||||
if (!list_insert(&in->inode->dirents, new)) {
|
if (!list_insert(&in->inode->dirents, new)) {
|
||||||
inode_dec_ref_lock(to);
|
|
||||||
dirent_free(new);
|
dirent_free(new);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue