lkml.org 
[lkml]   [2006]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] fix potential null deref in kallsyms::read_symbol
Date

The Coverity checker found that if malloc() fails in
scripts/kallsyms.c::read_symbol() then we end up dereferencing a NULL pointer.

Unlikely to happen, but we really should check the malloc() return value.
This patch fixes the problem by checking the return value and printing a nice
descriptive error message and exiting if malloc() did fail.

This fixes coverity error #397


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

scripts/kallsyms.c | 5 +++++
1 files changed, 5 insertions(+)

--- linux-2.6.16-rc5-git12-orig/scripts/kallsyms.c 2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.16-rc5-git12/scripts/kallsyms.c 2006-03-09 22:57:13.000000000 +0100
@@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct
* 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;




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-09 23:04    [W:0.033 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site