Skip to contentSkip to conversation

ensure NULL deref can't possibly happen in is_exported()

PATCH New Jesper Juhl 1 participant 1 message May 7, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ensure NULL deref can't possibly happen in is_exported()

If CONFIG_KALLSYMS is defined and if it should happen that is_exported() is given a NULL 'mod' and
lookup_symbol(name, __start___ksymtab, __stop___ksymtab) returns 0, then we'll end up dereferencing a NULL pointer.

Patch below makes sure that'll never happen.

---

 kernel/module.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
kernel/module.c +1 -1
@@ -1326,7 +1326,7 @@ int is_exported(const char *name, const 
 	if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab))
 		return 1;
 	else
-		if (lookup_symbol(name, mod->syms, mod->syms + mod->num_syms))
+		if (mod && lookup_symbol(name, mod->syms, mod->syms + mod->num_syms))
 			return 1;
 		else
 			return 0;