Fix panic when loading kernel modules before root file system is mounted.

Make sure the rootvnode is always NULL checked.

Differential Revision:	https://reviews.freebsd.org/D22545
PR:		241639
MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2019-11-26 12:20:44 +00:00
parent e3338dee08
commit aa4612d133
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355108

View File

@ -2079,14 +2079,16 @@ linker_load_module(const char *kldname, const char *modname,
*/
KASSERT(verinfo == NULL, ("linker_load_module: verinfo"
" is not NULL"));
if (rootvnode == NULL)
return (ENXIO);
pathname = linker_search_kld(kldname);
} else {
if (modlist_lookup2(modname, verinfo) != NULL)
return (EEXIST);
if (rootvnode == NULL)
return (ENXIO);
if (kldname != NULL)
pathname = strdup(kldname, M_LINKER);
else if (rootvnode == NULL)
pathname = NULL;
else
/*
* Need to find a KLD with required module