o avoid potential null ptr deref if symbol lookup fails

o unload module if symbol lookup fails

Noticed by:	Coverity Prevent analysis tool (null ptr deref)
Reviewed by:	bms, imp, dwhite
This commit is contained in:
Sam Leffler 2005-02-25 20:50:20 +00:00
parent 3b30e64d22
commit d40b07dfe4

View File

@ -792,9 +792,13 @@ digi_loadmoduledata(struct digi_softc *sc)
sym = malloc(modlen + 10, M_TEMP, M_WAITOK);
snprintf(sym, modlen + 10, "digi_mod_%s", sc->module);
if ((symptr = linker_file_lookup_symbol(lf, sym, 0)) == NULL)
printf("digi_%s.ko: Symbol `%s' not found\n", sc->module, sym);
symptr = linker_file_lookup_symbol(lf, sym, 0);
free(sym, M_TEMP);
if (symptr == NULL) {
printf("digi_%s.ko: Symbol `%s' not found\n", sc->module, sym);
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
return (EINVAL);
}
digi_mod = (struct digi_mod *)symptr;
if (digi_mod->dm_version != DIGI_MOD_VERSION) {