[RFC PATCH] genksyms: fix segmentation fault when parsing redefinition of typedef

From: Sheng Yong
Date: Tue Mar 03 2015 - 03:13:58 EST


Check if name is NULL to avoid segmentation fault when generate crc32
value. Otherwise, it is not easy to find out what is wrong in the code.
If name is NULL, just return it and continue, then gcc could find out
the incorrect position.

Signed-off-by: Sheng Yong <shengyong1@xxxxxxxxxx>
---
scripts/genksyms/genksyms.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 88632df..ba6cfa9 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -233,11 +233,11 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,
free_list(last_enum_expr, NULL);
last_enum_expr = NULL;
enum_counter = 0;
- if (!name)
- /* Anonymous enum definition, nothing more to do */
- return NULL;
}

+ if (!name)
+ return NULL;
+
h = crc32(name) % HASH_BUCKETS;
for (sym = symtab[h]; sym; sym = sym->hash_next) {
if (map_to_ns(sym->type) == map_to_ns(type) &&
--
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/