Fix panic on e.g. "kldload /dev/null".

PR:		kern/121427
Reviewed by:	sem
MFC after:	3 days
This commit is contained in:
ru 2008-03-15 17:40:18 +00:00
parent b9046423ec
commit a786aa30ca
2 changed files with 9 additions and 0 deletions

View File

@ -571,6 +571,11 @@ link_elf_load_file(linker_class_t cls, const char* filename,
return error;
vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp->v_type != VREG) {
error = ENOEXEC;
firstpage = NULL;
goto out;
}
#ifdef MAC
error = mac_kld_check_load(curthread->td_ucred, nd.ni_vp);
if (error) {

View File

@ -409,6 +409,10 @@ link_elf_load_file(linker_class_t cls, const char *filename,
return error;
vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp->v_type != VREG) {
error = ENOEXEC;
goto out;
}
#ifdef MAC
error = mac_kld_check_load(td->td_ucred, nd.ni_vp);
if (error) {