Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scripts: modpost: check memory allocation results

Fix missing error check for memory allocation functions in
scripts/mod/modpost.c.

Fixes kernel bugzilla #200319:
https://bugzilla.kernel.org/show_bug.cgi?id=200319

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Yuexing Wang <wangyxlandq@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

authored by

Randy Dunlap and committed by
Masahiro Yamada
1f3aa900 f498926c

+4 -4
+4 -4
scripts/mod/modpost.c
··· 672 672 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) 673 673 break; 674 674 if (symname[0] == '.') { 675 - char *munged = strdup(symname); 675 + char *munged = NOFAIL(strdup(symname)); 676 676 munged[0] = '_'; 677 677 munged[1] = toupper(munged[1]); 678 678 symname = munged; ··· 1318 1318 static char *sec2annotation(const char *s) 1319 1319 { 1320 1320 if (match(s, init_exit_sections)) { 1321 - char *p = malloc(20); 1321 + char *p = NOFAIL(malloc(20)); 1322 1322 char *r = p; 1323 1323 1324 1324 *p++ = '_'; ··· 1338 1338 strcat(p, " "); 1339 1339 return r; 1340 1340 } else { 1341 - return strdup(""); 1341 + return NOFAIL(strdup("")); 1342 1342 } 1343 1343 } 1344 1344 ··· 2036 2036 { 2037 2037 if (buf->size - buf->pos < len) { 2038 2038 buf->size += len + SZ; 2039 - buf->p = realloc(buf->p, buf->size); 2039 + buf->p = NOFAIL(realloc(buf->p, buf->size)); 2040 2040 } 2041 2041 strncpy(buf->p + buf->pos, s, len); 2042 2042 buf->pos += len;