Skip to content

Commit

Permalink
scripts: modpost: check memory allocation results
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Yuexing Wang <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
rddunlap authored and masahir0y committed Aug 22, 2018
1 parent f498926 commit 1f3aa90
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
break;
if (symname[0] == '.') {
char *munged = strdup(symname);
char *munged = NOFAIL(strdup(symname));
munged[0] = '_';
munged[1] = toupper(munged[1]);
symname = munged;
Expand Down Expand Up @@ -1318,7 +1318,7 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
static char *sec2annotation(const char *s)
{
if (match(s, init_exit_sections)) {
char *p = malloc(20);
char *p = NOFAIL(malloc(20));
char *r = p;

*p++ = '_';
Expand All @@ -1338,7 +1338,7 @@ static char *sec2annotation(const char *s)
strcat(p, " ");
return r;
} else {
return strdup("");
return NOFAIL(strdup(""));
}
}

Expand Down Expand Up @@ -2036,7 +2036,7 @@ void buf_write(struct buffer *buf, const char *s, int len)
{
if (buf->size - buf->pos < len) {
buf->size += len + SZ;
buf->p = realloc(buf->p, buf->size);
buf->p = NOFAIL(realloc(buf->p, buf->size));
}
strncpy(buf->p + buf->pos, s, len);
buf->pos += len;
Expand Down

0 comments on commit 1f3aa90

Please sign in to comment.