[PATCH] fix oprofile vfree warning on error

Anton Blanchard
2004-09-04T17:55:04Z

On error we can call __free_cpu_buffers with only some buffers
allocated. I was getting a bunch of vfree warnings when I hit it, we
should check before calling vfree.

Signed-off-by: Anton Blanchard <anton@samba.org>

diff -puN drivers/oprofile/cpu_buffer.c~oprofile_vfree_fix drivers/oprofile/cpu_buffer.c
--- linux-2.5/drivers/oprofile/cpu_buffer.c~oprofile_vfree_fix 2004-09-05 02:37:38.223212931 +1000
+++ linux-2.5-anton/drivers/oprofile/cpu_buffer.c 2004-09-05 02:37:43.608142109 +1000
@@ -36,8 +36,10 @@ static void __free_cpu_buffers(int num)
{
int i;

- for_each_online_cpu(i)
- vfree(cpu_buffer[i].buffer);
+ for_each_online_cpu(i) {
+ if (cpu_buffer[i].buffer)
+ vfree(cpu_buffer[i].buffer);
+ }
}

_