mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-19 10:53:58 +00:00
dynamically allocate the task structure in firmware_mountroot: when
booting from an MFS root (e.g. from an install CD) firmware_mountroot can be called twice with the second call happening before the task callback occurs; this results in the task structure contents being corrupted because it was declared static. Submitted by: marius (original version)
This commit is contained in:
parent
5899d29bc6
commit
73254c9ee7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183614
@ -386,6 +386,8 @@ set_rootvnode(void *arg, int npending)
|
||||
VREF(rootvnode);
|
||||
}
|
||||
FILEDESC_XUNLOCK(p->p_fd);
|
||||
|
||||
free(arg, M_TEMP);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -395,10 +397,14 @@ set_rootvnode(void *arg, int npending)
|
||||
static void
|
||||
firmware_mountroot(void *arg)
|
||||
{
|
||||
static struct task setroot_task;
|
||||
struct task *setroot_task;
|
||||
|
||||
TASK_INIT(&setroot_task, 0, set_rootvnode, NULL);
|
||||
taskqueue_enqueue(firmware_tq, &setroot_task);
|
||||
setroot_task = malloc(sizeof(struct task), M_TEMP, M_NOWAIT);
|
||||
if (setroot_task != NULL) {
|
||||
TASK_INIT(setroot_task, 0, set_rootvnode, setroot_task);
|
||||
taskqueue_enqueue(firmware_tq, setroot_task);
|
||||
} else
|
||||
printf("%s: no memory for task!\n", __func__);
|
||||
}
|
||||
EVENTHANDLER_DEFINE(mountroot, firmware_mountroot, NULL, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user