Skip to content

Commit 1f3aa90

Browse files
rddunlapmasahir0y
authored andcommitted
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>
1 parent f498926 commit 1f3aa90

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎scripts/mod/modpost.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
672672
if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
673673
break;
674674
if (symname[0] == '.') {
675-
char *munged = strdup(symname);
675+
char *munged = NOFAIL(strdup(symname));
676676
munged[0] = '_';
677677
munged[1] = toupper(munged[1]);
678678
symname = munged;
@@ -1318,7 +1318,7 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
13181318
static char *sec2annotation(const char *s)
13191319
{
13201320
if (match(s, init_exit_sections)) {
1321-
char *p = malloc(20);
1321+
char *p = NOFAIL(malloc(20));
13221322
char *r = p;
13231323

13241324
*p++ = '_';
@@ -1338,7 +1338,7 @@ static char *sec2annotation(const char *s)
13381338
strcat(p, " ");
13391339
return r;
13401340
} else {
1341-
return strdup("");
1341+
return NOFAIL(strdup(""));
13421342
}
13431343
}
13441344

@@ -2036,7 +2036,7 @@ void buf_write(struct buffer *buf, const char *s, int len)
20362036
{
20372037
if (buf->size - buf->pos < len) {
20382038
buf->size += len + SZ;
2039-
buf->p = realloc(buf->p, buf->size);
2039+
buf->p = NOFAIL(realloc(buf->p, buf->size));
20402040
}
20412041
strncpy(buf->p + buf->pos, s, len);
20422042
buf->pos += len;

0 commit comments

Comments
 (0)