Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756236AbcCOONX (ORCPT ); Tue, 15 Mar 2016 10:13:23 -0400 Received: from m12-13.163.com ([220.181.12.13]:51554 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754106AbcCOONT (ORCPT ); Tue, 15 Mar 2016 10:13:19 -0400 From: Geliang Tang To: Steven Rostedt , Ingo Molnar Cc: Geliang Tang , linux-kernel@vger.kernel.org Subject: [PATCH] ftrace: use kasprintf() in ftrace_profile_tracefs() Date: Tue, 15 Mar 2016 22:12:34 +0800 Message-Id: <135a7bc36e51fd9eaa57124dd2140285b771f738.1458050835.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 X-CM-TRANSID: DcCowAC3QlZVGOhWclGsAA--.12977S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr43Xw1DXr1UKr43Zr4xZwb_yoWDArgEvF 1kGws5Kr17C34vkr4rCrWxXrWjq3yUWF1ktw4ftrW3Aw1UGw1rG3WDurnxGF45Xrs2gF9I 9wnxXr1kKr1agjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUUdWFUUUUUU== X-Originating-IP: [119.123.183.152] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiJRgtmVUL+f4XiQAAsO Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1006 Lines: 32 Use kasprintf() instead of kmalloc() and snprintf(). Signed-off-by: Geliang Tang --- 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