Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966685AbcCPOTM (ORCPT ); Wed, 16 Mar 2016 10:19:12 -0400 Received: from mail-ig0-f171.google.com ([209.85.213.171]:36972 "EHLO mail-ig0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933008AbcCPOTK (ORCPT ); Wed, 16 Mar 2016 10:19:10 -0400 MIME-Version: 1.0 In-Reply-To: <135a7bc36e51fd9eaa57124dd2140285b771f738.1458050835.git.geliangtang@163.com> References: <135a7bc36e51fd9eaa57124dd2140285b771f738.1458050835.git.geliangtang@163.com> Date: Wed, 16 Mar 2016 23:19:08 +0900 X-Google-Sender-Auth: QAQmuJ1ISAiw8hPWfrtmkQZqB34 Message-ID: Subject: Re: [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs() From: Namhyung Kim To: Geliang Tang Cc: Steven Rostedt , Ingo Molnar , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1430 Lines: 43 Hi Geliang, On Tue, Mar 15, 2016 at 11:12 PM, Geliang Tang wrote: > Use kasprintf() instead of kmalloc() and snprintf(). > > Signed-off-by: Geliang Tang Acked-by: Namhyung Kim 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 > >