From: Jesper Juhl Date: Sat, 25 Mar 2006 11:07:46 +0000 (-0800) Subject: [PATCH] kallsyms: handle malloc() failure X-Git-Tag: v2.6.17-rc1~788 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f1a136e0d098a4478236a1c24f9a57db5abf0755;p=linux-2.6-omap-h63xx.git [PATCH] kallsyms: handle malloc() failure This fixes coverity bugs #398 and #397 Signed-off-by: Jesper Juhl Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index d591578bd3b..22d281c6ec2 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -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; @@ -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;