Messages in this thread | | | Subject | Re: ftrace does not work on cpus > 999. | From | Steven Rostedt <> | Date | Sat, 16 Oct 2010 11:17:52 -0400 |
| |
On Sat, 2010-10-16 at 16:45 +0200, Frederic Weisbecker wrote:
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 9ec59f5..3565f9e 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -3999,7 +3999,7 @@ static void tracing_init_debugfs_percpu(long cpu) > /* strlen(cpu) + MAX(log10(cpu)) + '\0' */ > char cpu_dir[7]; > > - if (cpu > 999 || cpu < 0) > + if (cpu < 0) > return; > > sprintf(cpu_dir, "cpu%ld", cpu);
You need to change the size of cpu_dir, otherwise this will overflow.
The other case is to dynamically allocate cpu_dir.
char *cpu_dir; int count = cpu; int size;
if (cpu < 0) return;
/* log10 sizeof cpu */ for (size = 0; count > 0; count /= 10, size++) ;
cpu_dir = kmalloc(size + 4, GFP_KERNEL);
if (!cpu_dir) return;
snprintf(cpu_dir, size + 4, "cpu%ld", cpu);
[...]
kfree(cpu_dir);
-- Steve
| |