Commit f1a136e0 authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] kallsyms: handle malloc() failure

This fixes coverity bugs #398 and #397
Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2ab13460
...@@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct sym_entry *s) ...@@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct sym_entry *s)
* compressed together */ * compressed together */
s->len = strlen(str) + 1; s->len = strlen(str) + 1;
s->sym = malloc(s->len + 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); strcpy((char *)s->sym + 1, str);
s->sym[0] = stype; s->sym[0] = stype;
...@@ -272,7 +277,12 @@ static void write_src(void) ...@@ -272,7 +277,12 @@ static void write_src(void)
/* table of offset markers, that give the offset in the compressed stream /* table of offset markers, that give the offset in the compressed stream
* every 256 symbols */ * 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"); output_label("kallsyms_names");
off = 0; off = 0;
......
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