From d40b07dfe4f1b86e93fb6cd509997ced7c066c84 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Fri, 25 Feb 2005 20:50:20 +0000 Subject: [PATCH] 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 --- sys/dev/digi/digi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/digi/digi.c b/sys/dev/digi/digi.c index 5ecc6018689..7f68c02f175 100644 --- a/sys/dev/digi/digi.c +++ b/sys/dev/digi/digi.c @@ -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) {