diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2006-03-25 06:07:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-25 11:22:56 -0500 |
commit | f1a136e0d098a4478236a1c24f9a57db5abf0755 (patch) | |
tree | d65627ea5c9b4124cc456048da0d3ab5fb2dd5dd /scripts/kallsyms.c | |
parent | 2ab13460852e65c2ec0e77000baba5e859a6a2cf (diff) |
[PATCH] kallsyms: handle malloc() failure
This fixes coverity bugs #398 and #397
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/kallsyms.c')
-rw-r--r-- | scripts/kallsyms.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index d591578bd3b2..22d281c6ec24 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct sym_entry *s) | |||
124 | * compressed together */ | 124 | * compressed together */ |
125 | s->len = strlen(str) + 1; | 125 | s->len = strlen(str) + 1; |
126 | s->sym = malloc(s->len + 1); | 126 | s->sym = malloc(s->len + 1); |
127 | if (!s->sym) { | ||
128 | fprintf(stderr, "kallsyms failure: " | ||
129 | "unable to allocate required amount of memory\n"); | ||
130 | exit(EXIT_FAILURE); | ||
131 | } | ||
127 | strcpy((char *)s->sym + 1, str); | 132 | strcpy((char *)s->sym + 1, str); |
128 | s->sym[0] = stype; | 133 | s->sym[0] = stype; |
129 | 134 | ||
@@ -272,7 +277,12 @@ static void write_src(void) | |||
272 | 277 | ||
273 | /* table of offset markers, that give the offset in the compressed stream | 278 | /* table of offset markers, that give the offset in the compressed stream |
274 | * every 256 symbols */ | 279 | * every 256 symbols */ |
275 | markers = (unsigned int *) malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256)); | 280 | markers = malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256)); |
281 | if (!markers) { | ||
282 | fprintf(stderr, "kallsyms failure: " | ||
283 | "unable to allocate required memory\n"); | ||
284 | exit(EXIT_FAILURE); | ||
285 | } | ||
276 | 286 | ||
277 | output_label("kallsyms_names"); | 287 | output_label("kallsyms_names"); |
278 | off = 0; | 288 | off = 0; |