diff options
author | Toomas Soome <tsoome@FreeBSD.org> | 2019-04-07 12:20:17 +0000 |
---|---|---|
committer | Toomas Soome <tsoome@FreeBSD.org> | 2019-04-07 12:20:17 +0000 |
commit | d7125bb1e21b413f32e87bdf086355eb5bcdc6a7 (patch) | |
tree | 02c22df0c29541f1cf268ce7589f279aef914685 /stand/common/module.c | |
parent | d28c59466939a38767424e6bf61d884b8df89466 (diff) | |
download | src-d7125bb1e21b413f32e87bdf086355eb5bcdc6a7.tar.gz src-d7125bb1e21b413f32e87bdf086355eb5bcdc6a7.zip |
loader: mod_loadkld() error: we previously assumed 'last_file' could be null
The last_file variable is used to reset the loadaddr variable back to original
value; however, it is possible the last_file is NULL, so we can not blindly
trust it. But then again, we can just save the original loadaddr and use
the saved value for recovery.
MFC after: 1w
Notes
Notes:
svn path=/head/; revision=346002
Diffstat (limited to 'stand/common/module.c')
-rw-r--r-- | stand/common/module.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/stand/common/module.c b/stand/common/module.c index fea856a395f7..3e79df50be1f 100644 --- a/stand/common/module.c +++ b/stand/common/module.c @@ -559,9 +559,10 @@ mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[]) int mod_loadkld(const char *kldname, int argc, char *argv[]) { - struct preloaded_file *fp, *last_file; - int err; + struct preloaded_file *fp; + int err; char *filename; + vm_offset_t loadaddr_saved; /* * Get fully qualified KLD name @@ -582,22 +583,19 @@ mod_loadkld(const char *kldname, int argc, char *argv[]) free(filename); return (0); } - for (last_file = preloaded_files; - last_file != NULL && last_file->f_next != NULL; - last_file = last_file->f_next) - ; do { err = file_load(filename, loadaddr, &fp); if (err) break; fp->f_args = unargv(argc, argv); + loadaddr_saved = loadaddr; loadaddr = fp->f_addr + fp->f_size; file_insert_tail(fp); /* Add to the list of loaded files */ if (file_load_dependencies(fp) != 0) { err = ENOENT; last_file->f_next = NULL; - loadaddr = last_file->f_addr + last_file->f_size; + loadaddr = loadaddr_saved; fp = NULL; break; } |