Skip to content

Commit

Permalink
[PATCH] kallsyms: handle malloc() failure
Browse files Browse the repository at this point in the history
This fixes coverity bugs torvalds#398 and torvalds#397

Signed-off-by: Jesper Juhl <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jesper Juhl authored and Linus Torvalds committed Mar 25, 2006
1 parent 2ab1346 commit f1a136e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct sym_entry *s)
* compressed together */
s->len = strlen(str) + 1;
s->sym = malloc(s->len + 1);
if (!s->sym) {
fprintf(stderr, "kallsyms failure: "
"unable to allocate required amount of memory\n");
exit(EXIT_FAILURE);
}
strcpy((char *)s->sym + 1, str);
s->sym[0] = stype;

Expand Down Expand Up @@ -272,7 +277,12 @@ static void write_src(void)

/* table of offset markers, that give the offset in the compressed stream
* every 256 symbols */
markers = (unsigned int *) malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256));
markers = malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256));
if (!markers) {
fprintf(stderr, "kallsyms failure: "
"unable to allocate required memory\n");
exit(EXIT_FAILURE);
}

output_label("kallsyms_names");
off = 0;
Expand Down

0 comments on commit f1a136e

Please sign in to comment.