diff options
author | Carsten Emde <C.Emde@osadl.org> | 2010-02-24 07:49:32 +0100 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-02-24 12:10:52 +0100 |
commit | d28b33f44b57ec171be735fd12511e6059672376 (patch) | |
tree | 36e731f3867f5170e0208f8cc78b1fb86f327754 | |
parent | 2022ce18f08a62593979bd3875111ee010b57d43 (diff) | |
download | lwn-d28b33f44b57ec171be735fd12511e6059672376.tar.gz lwn-d28b33f44b57ec171be735fd12511e6059672376.zip |
tracing: Plug memory leak in histogram_show
Do not allocate memory for index pointer, if index out of range.
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | kernel/trace/latency_hist.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/kernel/trace/latency_hist.c b/kernel/trace/latency_hist.c index 8300929b0f1d..9f20d6136416 100644 --- a/kernel/trace/latency_hist.c +++ b/kernel/trace/latency_hist.c @@ -218,13 +218,10 @@ void notrace latency_hist(int latency_type, int cpu, unsigned long latency, static void *l_start(struct seq_file *m, loff_t *pos) { - loff_t *index_ptr = kmalloc(sizeof(loff_t), GFP_KERNEL); + loff_t *index_ptr = NULL; loff_t index = *pos; struct hist_data *my_hist = m->private; - if (!index_ptr) - return NULL; - if (index == 0) { char minstr[32], avgstr[32], maxstr[32]; @@ -263,10 +260,12 @@ static void *l_start(struct seq_file *m, loff_t *pos) MAX_ENTRY_NUM - my_hist->offset, "samples"); } - if (index >= MAX_ENTRY_NUM) - return NULL; + if (index < MAX_ENTRY_NUM) { + index_ptr = kmalloc(sizeof(loff_t), GFP_KERNEL); + if (index_ptr) + *index_ptr = index; + } - *index_ptr = index; return index_ptr; } |