kbuild: fix segv in modpost

Parsing an old Modules.symvers file casued modpost to SEGV.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

+6 -3
+6 -3
scripts/mod/modpost.c
··· 205 205 static enum export export_no(const char * s) 206 206 { 207 207 int i; 208 + if (!s) 209 + return export_unknown; 208 210 for (i = 0; export_list[i].export != export_unknown; i++) { 209 211 if (strcmp(export_list[i].str, s) == 0) 210 212 return export_list[i].export; ··· 1273 1271 } 1274 1272 1275 1273 /* parse Module.symvers file. line format: 1276 - * 0x12345678<tab>symbol<tab>module[<tab>export] 1274 + * 0x12345678<tab>symbol<tab>module[[<tab>export]<tab>something] 1277 1275 **/ 1278 1276 static void read_dump(const char *fname, unsigned int kernel) 1279 1277 { ··· 1286 1284 return; 1287 1285 1288 1286 while ((line = get_next_line(&pos, file, size))) { 1289 - char *symname, *modname, *d, *export; 1287 + char *symname, *modname, *d, *export, *end; 1290 1288 unsigned int crc; 1291 1289 struct module *mod; 1292 1290 struct symbol *s; ··· 1299 1297 *modname++ = '\0'; 1300 1298 if ((export = strchr(modname, '\t')) != NULL) 1301 1299 *export++ = '\0'; 1302 - 1300 + if (export && ((end = strchr(export, '\t')) != NULL)) 1301 + *end = '\0'; 1303 1302 crc = strtoul(line, &d, 16); 1304 1303 if (*symname == '\0' || *modname == '\0' || *d != '\0') 1305 1304 goto fail;