mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Robin Holt <holt@sgi.com>, Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: ftrace does not work on cpus > 999.
Date: Sat, 16 Oct 2010 11:17:52 -0400	[thread overview]
Message-ID: <1287242272.16971.53.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20101016144529.GA5384@nowhere>

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



  reply	other threads:[~2010-10-16 15:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-16 13:15 Robin Holt
2010-10-16 14:45 ` Frederic Weisbecker
2010-10-16 15:17   ` Steven Rostedt [this message]
2010-10-16 16:16     ` Ingo Molnar
2010-10-16 16:32       ` Steven Rostedt
2010-10-16 16:32       ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287242272.16971.53.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=holt@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®