linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs()
@ 2016-03-15 14:12 Geliang Tang
  2016-03-16 14:19 ` Namhyung Kim
  2016-03-18 14:31 ` Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: Geliang Tang @ 2016-03-15 14:12 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar; +Cc: Geliang Tang, linux-kernel

Use kasprintf() instead of kmalloc() and snprintf().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 kernel/trace/ftrace.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2ece9f1..69aceae 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1030,8 +1030,7 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
 	for_each_possible_cpu(cpu) {
 		stat = &per_cpu(ftrace_profile_stats, cpu);
 
-		/* allocate enough for function name + cpu number */
-		name = kmalloc(32, GFP_KERNEL);
+		name = kasprintf(GFP_KERNEL, "function%d", cpu);
 		if (!name) {
 			/*
 			 * The files created are permanent, if something happens
@@ -1043,7 +1042,6 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
 			return;
 		}
 		stat->stat = function_stats;
-		snprintf(name, 32, "function%d", cpu);
 		stat->stat.name = name;
 		ret = register_stat_tracer(&stat->stat);
 		if (ret) {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs()
  2016-03-15 14:12 [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs() Geliang Tang
@ 2016-03-16 14:19 ` Namhyung Kim
  2016-03-16 14:32   ` Steven Rostedt
  2016-03-18 14:31 ` Steven Rostedt
  1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2016-03-16 14:19 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Steven Rostedt, Ingo Molnar, LKML

Hi Geliang,

On Tue, Mar 15, 2016 at 11:12 PM, Geliang Tang <geliangtang@163.com> wrote:
> Use kasprintf() instead of kmalloc() and snprintf().
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  kernel/trace/ftrace.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 2ece9f1..69aceae 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -1030,8 +1030,7 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
>         for_each_possible_cpu(cpu) {
>                 stat = &per_cpu(ftrace_profile_stats, cpu);
>
> -               /* allocate enough for function name + cpu number */
> -               name = kmalloc(32, GFP_KERNEL);
> +               name = kasprintf(GFP_KERNEL, "function%d", cpu);
>                 if (!name) {
>                         /*
>                          * The files created are permanent, if something happens
> @@ -1043,7 +1042,6 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
>                         return;
>                 }
>                 stat->stat = function_stats;
> -               snprintf(name, 32, "function%d", cpu);
>                 stat->stat.name = name;
>                 ret = register_stat_tracer(&stat->stat);
>                 if (ret) {
> --
> 2.5.0
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs()
  2016-03-16 14:19 ` Namhyung Kim
@ 2016-03-16 14:32   ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2016-03-16 14:32 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Geliang Tang, Ingo Molnar, LKML

On Wed, 16 Mar 2016 23:19:08 +0900
Namhyung Kim <namhyung@gmail.com> wrote:

> Hi Geliang,
> 
> On Tue, Mar 15, 2016 at 11:12 PM, Geliang Tang <geliangtang@163.com> wrote:
> > Use kasprintf() instead of kmalloc() and snprintf().
> >
> > Signed-off-by: Geliang Tang <geliangtang@163.com>  
> 
> Acked-by: Namhyung Kim <namhyung@kernel.org>
>

Thanks, I'll pull this in to my pull request. I'm currently working on
some other things, but need to get my pull ready soon. I'll work on
this tomorrow.

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs()
  2016-03-15 14:12 [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs() Geliang Tang
  2016-03-16 14:19 ` Namhyung Kim
@ 2016-03-18 14:31 ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2016-03-18 14:31 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Ingo Molnar, linux-kernel

On Tue, 15 Mar 2016 22:12:34 +0800
Geliang Tang <geliangtang@163.com> wrote:

> Use kasprintf() instead of kmalloc() and snprintf().
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>

Thanks, applied!

-- Steve

> ---
>  kernel/trace/ftrace.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 2ece9f1..69aceae 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -1030,8 +1030,7 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
>  	for_each_possible_cpu(cpu) {
>  		stat = &per_cpu(ftrace_profile_stats, cpu);
>  
> -		/* allocate enough for function name + cpu number */
> -		name = kmalloc(32, GFP_KERNEL);
> +		name = kasprintf(GFP_KERNEL, "function%d", cpu);
>  		if (!name) {
>  			/*
>  			 * The files created are permanent, if something happens
> @@ -1043,7 +1042,6 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
>  			return;
>  		}
>  		stat->stat = function_stats;
> -		snprintf(name, 32, "function%d", cpu);
>  		stat->stat.name = name;
>  		ret = register_stat_tracer(&stat->stat);
>  		if (ret) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-18 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-15 14:12 [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs() Geliang Tang
2016-03-16 14:19 ` Namhyung Kim
2016-03-16 14:32   ` Steven Rostedt
2016-03-18 14:31 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).