svn commit: r355419 - stable/10/sys/kern
Hans Petter Selasky
hselasky at FreeBSD.org
Thu Dec 5 14:53:47 UTC 2019
Author: hselasky
Date: Thu Dec 5 14:53:46 2019
New Revision: 355419
URL: https://svnweb.freebsd.org/changeset/base/355419
Log:
MFC r355108 and r355170:
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
Sponsored by: Mellanox Technologies
Modified:
stable/10/sys/kern/kern_linker.c
stable/10/sys/kern/subr_firmware.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/kern/kern_linker.c
==============================================================================
--- stable/10/sys/kern/kern_linker.c Thu Dec 5 14:52:06 2019 (r355418)
+++ stable/10/sys/kern/kern_linker.c Thu Dec 5 14:53:46 2019 (r355419)
@@ -2000,14 +2000,18 @@ linker_load_module(const char *kldname, const char *mo
*/
KASSERT(verinfo == NULL, ("linker_load_module: verinfo"
" is not NULL"));
+ /* check if root file system is not mounted */
+ if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL)
+ return (ENXIO);
pathname = linker_search_kld(kldname);
} else {
if (modlist_lookup2(modname, verinfo) != NULL)
return (EEXIST);
+ /* check if root file system is not mounted */
+ if (rootvnode == NULL || curproc->p_fd->fd_rdir == 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
Modified: stable/10/sys/kern/subr_firmware.c
==============================================================================
--- stable/10/sys/kern/subr_firmware.c Thu Dec 5 14:52:06 2019 (r355418)
+++ stable/10/sys/kern/subr_firmware.c Thu Dec 5 14:53:46 2019 (r355419)
@@ -255,7 +255,6 @@ firmware_unregister(const char *imagename)
static void
loadimage(void *arg, int npending)
{
- struct thread *td = curthread;
char *imagename = arg;
struct priv_fw *fp;
linker_file_t result;
@@ -265,11 +264,6 @@ loadimage(void *arg, int npending)
mtx_lock(&firmware_mtx);
mtx_unlock(&firmware_mtx);
- if (td->td_proc->p_fd->fd_rdir == NULL) {
- printf("%s: root not mounted yet, no way to load image\n",
- imagename);
- goto done;
- }
error = linker_reference_module(imagename, NULL, &result);
if (error != 0) {
printf("%s: could not load firmware image, error %d\n",
More information about the svn-src-stable
mailing list