only do the temporary symbol table load #ifdef DDB and add comment for

the code block, so that the purpose is more clear

avoid NULL pointer dereference in lkmunreserve() called on lkm device
close when ksym_addsymtab() fails for the temporary symbol table
(sanity change only, this can never happen at the moment)
This commit is contained in:
jdolecek 2004-12-30 11:47:02 +00:00
parent b90395b379
commit aca74c5304
1 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lkm.c,v 1.79 2004/12/30 11:35:41 jdolecek Exp $ */
/* $NetBSD: kern_lkm.c,v 1.80 2004/12/30 11:47:02 jdolecek Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.79 2004/12/30 11:35:41 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.80 2004/12/30 11:47:02 jdolecek Exp $");
#include "opt_ddb.h"
#include "opt_malloclog.h"
@ -483,18 +483,27 @@ lkmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
curp->size - curp->offset);
}
#ifdef DDB
/*
* Temporarily load the symbol table before the entry
* routine is called, so that the symbols are available
* for DDB backtrace and breakpoints.
*/
if (curp->syms && curp->sym_offset >= curp->sym_size) {
error = ksyms_addsymtab("/lkmtemp/",
(char *)curp->syms, curp->sym_symsize,
(char *)curp->syms + curp->sym_symsize,
curp->sym_size - curp->sym_symsize);
if (error)
break;
goto rdyfail;
#ifdef DEBUG
if (lkmdebug & LKMDB_INFO)
printf( "DDB symbols added!\n" );
#endif
}
#endif /* DDB */
curp->entry = (int (*)(struct lkm_table *, int, int))
(*((long *) (data)));
@ -503,7 +512,9 @@ lkmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
error = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION);
if (curp->syms && curp->sym_offset >= curp->sym_size) {
#ifdef DDB
ksyms_delsymtab("/lkmtemp/");
#endif
if (!error) {
error = ksyms_addsymtab(curp->private.lkm_any->lkm_name,
@ -514,6 +525,7 @@ lkmioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
}
if (error) {
rdyfail:
/*
* Module may refuse loading or may have a
* version mismatch...