mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
file: fix possible null pointer access
This commit is contained in:
@@ -35,6 +35,13 @@ static file_t* newfile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void cleanfile(file_t *file) {
|
static void cleanfile(file_t *file) {
|
||||||
|
if (file->advlock) {
|
||||||
|
// try unlocking it if applicable
|
||||||
|
VOP_ADVLOCK(file->vnode, ADVLOCK_UNLOCK, file->advlock);
|
||||||
|
ADVLOCK_UNREF(file->advlock);
|
||||||
|
file->advlock = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (file->vnode) {
|
if (file->vnode) {
|
||||||
vfs_close(file->vnode, fileflagstovnodeflags(file->flags));
|
vfs_close(file->vnode, fileflagstovnodeflags(file->flags));
|
||||||
VOP_RELEASE(file->vnode);
|
VOP_RELEASE(file->vnode);
|
||||||
@@ -45,12 +52,6 @@ static void cleanfile(file_t *file) {
|
|||||||
file->flags = 0;
|
file->flags = 0;
|
||||||
file->mode = 0;
|
file->mode = 0;
|
||||||
MUTEX_INIT(&file->mutex);
|
MUTEX_INIT(&file->mutex);
|
||||||
if (file->advlock) {
|
|
||||||
// try unlocking it if applicable
|
|
||||||
VOP_ADVLOCK(file->vnode, ADVLOCK_UNLOCK, file->advlock);
|
|
||||||
ADVLOCK_UNREF(file->advlock);
|
|
||||||
file->advlock = NULL;
|
|
||||||
}
|
|
||||||
file->vnode = NULL;
|
file->vnode = NULL;
|
||||||
slab_free(filecache, file);
|
slab_free(filecache, file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user