From patchwork Tue Aug 6 01:30:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 11078071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D76EF13B1 for ; Tue, 6 Aug 2019 02:02:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4E9F288E5 for ; Tue, 6 Aug 2019 02:02:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6CE928981; Tue, 6 Aug 2019 02:02:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EF64288E5 for ; Tue, 6 Aug 2019 02:02:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6388316E2; Tue, 6 Aug 2019 03:43:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6388316E2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1565055848; bh=nupoMlHdSyUGeryGfly1fZEtb6Tsuqpt3L2N9XUh5f4=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fPh+7NSbUT+rfdRs8m2U9p+9rcp7UvA4JapA5FZMY28odin6QHAhDT/alz2aEtowo skTf9xoJaUp8o3tm2qEcw82yCHy6sAiQMfUIvYuZwJZ/CiLnrO5Mk45Yr9ZoDUh6VO GxIxK7hH1jezFqU/R3n81kAHDXEN+/ck7DhCmhbU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 977CDF80765; Tue, 6 Aug 2019 03:30:43 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7F23FF80768; Tue, 6 Aug 2019 03:30:42 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 4E831F80760 for ; Tue, 6 Aug 2019 03:30:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4E831F80760 Date: 06 Aug 2019 10:30:36 +0900 X-IronPort-AV: E=Sophos;i="5.64,350,1559487600"; d="scan'208";a="23193046" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 06 Aug 2019 10:30:36 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9913A4006DEE; Tue, 6 Aug 2019 10:30:36 +0900 (JST) Message-ID: <874l2v2ie8.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.5 Mule/6.0 To: Mark Brown In-Reply-To: <871rxz3x7e.wl-kuninori.morimoto.gx@renesas.com> References: <871rxz3x7e.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA Subject: [alsa-devel] [PATCH 23/28] ASoC: soc-core: don't alloc memory carelessly when creating debugfs X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current ALSA SoC might allocate debugfs name memory via kasprintf(), but, it is grandiose and the code becoming very complex. Using enough size local variable is very enough for this purpose. This patch uses 64byte local variable for it. It is very enough size for this purposeq. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-core.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c737349..bf3bda2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -147,23 +147,19 @@ static const struct attribute_group *soc_dev_attr_groups[] = { #ifdef CONFIG_DEBUG_FS static void soc_init_component_debugfs(struct snd_soc_component *component) { + char name[64]; + if (!component->card->debugfs_card_root) return; - if (component->debugfs_prefix) { - char *name; - - name = kasprintf(GFP_KERNEL, "%s:%s", + if (component->debugfs_prefix) + snprintf(name, ARRAY_SIZE(name), "%s:%s", component->debugfs_prefix, component->name); - if (name) { - component->debugfs_root = debugfs_create_dir(name, - component->card->debugfs_card_root); - kfree(name); - } - } else { - component->debugfs_root = debugfs_create_dir(component->name, - component->card->debugfs_card_root); - } + else + snprintf(name, ARRAY_SIZE(name), "%s", component->name); + + component->debugfs_root = debugfs_create_dir(name, + component->card->debugfs_card_root); snd_soc_dapm_debugfs_init(snd_soc_component_get_dapm(component), component->debugfs_root);