Commit ab4bddc2 authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman
Browse files

scripts: modpost: check memory allocation results

[ Upstream commit 1f3aa900 ]

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: default avatarRandy Dunlap <rdunlap@infradead.org>
Cc: Yuexing Wang <wangyxlandq@gmail.com>
Signed-off-by: Masahiro Yamada's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7bbf1e8a
...@@ -677,7 +677,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, ...@@ -677,7 +677,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
break; break;
if (symname[0] == '.') { if (symname[0] == '.') {
char *munged = strdup(symname); char *munged = NOFAIL(strdup(symname));
munged[0] = '_'; munged[0] = '_';
munged[1] = toupper(munged[1]); munged[1] = toupper(munged[1]);
symname = munged; symname = munged;
...@@ -1329,7 +1329,7 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, ...@@ -1329,7 +1329,7 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
static char *sec2annotation(const char *s) static char *sec2annotation(const char *s)
{ {
if (match(s, init_exit_sections)) { if (match(s, init_exit_sections)) {
char *p = malloc(20); char *p = NOFAIL(malloc(20));
char *r = p; char *r = p;
*p++ = '_'; *p++ = '_';
...@@ -1349,7 +1349,7 @@ static char *sec2annotation(const char *s) ...@@ -1349,7 +1349,7 @@ static char *sec2annotation(const char *s)
strcat(p, " "); strcat(p, " ");
return r; return r;
} else { } else {
return strdup(""); return NOFAIL(strdup(""));
} }
} }
...@@ -2050,7 +2050,7 @@ void buf_write(struct buffer *buf, const char *s, int len) ...@@ -2050,7 +2050,7 @@ void buf_write(struct buffer *buf, const char *s, int len)
{ {
if (buf->size - buf->pos < len) { if (buf->size - buf->pos < len) {
buf->size += len + SZ; 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); strncpy(buf->p + buf->pos, s, len);
buf->pos += len; buf->pos += len;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment