aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandy Dunlap <rdunlap@infradead.org>2018-08-15 15:30:38 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-08-22 10:21:40 -0400
commit1f3aa9002dc6a0d59a4b599b4fc8f01cf43ef014 (patch)
tree0c2549d32c719097ea6e9e37c05c272bbf0690f3
parentf498926c47aa7d4f1b6d08af2ba16f3cf8fcb151 (diff)
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>
-rw-r--r--scripts/mod/modpost.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index dc6d714e4dcb..0d998c54564d 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -672,7 +672,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
672 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) 672 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
673 break; 673 break;
674 if (symname[0] == '.') { 674 if (symname[0] == '.') {
675 char *munged = strdup(symname); 675 char *munged = NOFAIL(strdup(symname));
676 munged[0] = '_'; 676 munged[0] = '_';
677 munged[1] = toupper(munged[1]); 677 munged[1] = toupper(munged[1]);
678 symname = munged; 678 symname = munged;
@@ -1318,7 +1318,7 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
1318static char *sec2annotation(const char *s) 1318static char *sec2annotation(const char *s)
1319{ 1319{
1320 if (match(s, init_exit_sections)) { 1320 if (match(s, init_exit_sections)) {
1321 char *p = malloc(20); 1321 char *p = NOFAIL(malloc(20));
1322 char *r = p; 1322 char *r = p;
1323 1323
1324 *p++ = '_'; 1324 *p++ = '_';
@@ -1338,7 +1338,7 @@ static char *sec2annotation(const char *s)
1338 strcat(p, " "); 1338 strcat(p, " ");
1339 return r; 1339 return r;
1340 } else { 1340 } else {
1341 return strdup(""); 1341 return NOFAIL(strdup(""));
1342 } 1342 }
1343} 1343}
1344 1344
@@ -2036,7 +2036,7 @@ void buf_write(struct buffer *buf, const char *s, int len)
2036{ 2036{
2037 if (buf->size - buf->pos < len) { 2037 if (buf->size - buf->pos < len) {
2038 buf->size += len + SZ; 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 strncpy(buf->p + buf->pos, s, len); 2041 strncpy(buf->p + buf->pos, s, len);
2042 buf->pos += len; 2042 buf->pos += len;