From patchwork Mon Aug 31 09:08:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 291914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64B4CC433E2 for ; Mon, 31 Aug 2020 09:10:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2AB2208CA for ; Mon, 31 Aug 2020 09:10:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="OmBVrwPz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2AB2208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 48E7F182B; Mon, 31 Aug 2020 11:09:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 48E7F182B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865000; bh=+Q26Pgh/P+Ns91ADSBUrhWoGxlD+cFUamO3ZC4wZ9Xk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OmBVrwPzxkwbrF+6RGmYcC+hVdck9y/WZPd2yaZu6xLr9376eKQofX54ZP0khv+cb dz1Zz7s+Q0eLxf6hvimGx+0KJDUk4uZEJYA6m1F/ue2ebUC++TtqaD0DbUM3f+IGaQ CawKnEZyrCt+753Fc57xyUlipNtWMJICQTzxVSZ4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3C715F80212; Mon, 31 Aug 2020 11:08:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8B63AF80146; Mon, 31 Aug 2020 11:08:16 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 27D1BF80146 for ; Mon, 31 Aug 2020 11:08:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 27D1BF80146 IronPort-SDR: yJnZxtOD3N/TXp9zLCBMRW7gcACxPcoW3t9ZytNIL6qJOWMoB3ReR/xQYCaCkjtytd+gCT7cNa OSJYHDmIfBNA== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466737" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466737" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:03 -0700 IronPort-SDR: SpPDj+AQdaZ8Xb3k3GtLAwUQCtuAAbqvbE42EQ8HqJFclfOg+Et8mKh3VcucApByF0uhTT+Lxt Tal/Hs2NSoiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286858" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:02 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 01/10] topology: decode: Fix channel map memory allocation Date: Mon, 31 Aug 2020 11:08:54 +0200 Message-Id: <1598864943-22883-2-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Memory allocated on the stack was referenced outside of the function scope caused undefined behaviour. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/ctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 90241b6..6e6c1d1 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -1330,7 +1330,6 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, void *bin, size_t size) { struct snd_soc_tplg_enum_control *ec = bin; - struct snd_tplg_channel_map_template cmt; int i; if (size < sizeof(*ec)) { @@ -1375,11 +1374,13 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, } } - et->map = &cmt; - memset(&cmt, 0, sizeof(cmt)); - cmt.num_channels = ec->num_channels; - for (i = 0; i < cmt.num_channels; i++) { - struct snd_tplg_channel_elem *channel = &cmt.channel[i]; + et->map = tplg_calloc(heap, sizeof(struct snd_tplg_channel_map_template)); + if (!et->map) + return -ENOMEM; + et->map->num_channels = ec->num_channels; + for (i = 0; i < et->map->num_channels; i++) { + struct snd_tplg_channel_elem *channel = &et->map->channel[i]; + tplg_log(tplg, 'D', pos + ((void *)&ec->channel[i] - (void *)ec), "enum: channel size %d", ec->channel[i].size); channel->reg = ec->channel[i].reg; From patchwork Mon Aug 31 09:08:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 251226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DD9FC433E2 for ; Mon, 31 Aug 2020 09:10:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB5FC208DB for ; Mon, 31 Aug 2020 09:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="QtYHDfLY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB5FC208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 1A75B1768; Mon, 31 Aug 2020 11:09:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1A75B1768 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865047; bh=24LdW+IB1nVFbVhemfZXwgf2Vvy1wMbX+EGyuzaVDZo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QtYHDfLY9fV5xykfXAoLjtXbtwPEPks4DEDoPVGnvU5fffBHTEtjFqRtSZgXZfMbq /a3VM42Lrl0GLpiz65rwLnTb6K/FgBCehMvzDRl/zWM/ruyfJ2A1pkw5cudc2RZBlN ClfAfPCiMcwHmhGoOhlvgj50qWiQdskXlbmHn04I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DC3BAF802DC; Mon, 31 Aug 2020 11:08:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D56A1F802D2; Mon, 31 Aug 2020 11:08:19 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 51535F80212 for ; Mon, 31 Aug 2020 11:08:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 51535F80212 IronPort-SDR: Rzp1D7/xsQTDIgbjHKS8a/lj0ldrT7O22SJK/C4m8o3deyQcSicB7+mB0IRVbVBAOYnjfAMRZR 5O6E8YTUPoeQ== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466743" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466743" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:05 -0700 IronPort-SDR: qnT7Ccc3qE09Y/3QAQJYgCtF9M1wBcevhejJm6nStYaRvyRs4oyC+DSJ7ZEM/zMEFGiOLuOf3u mhEZANScjhiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286869" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:04 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 02/10] topology: decode: Fix infinite loop in decoding enum control Date: Mon, 31 Aug 2020 11:08:55 +0200 Message-Id: <1598864943-22883-3-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Accessing memory outside of allocated boundaries caused segmentation fault. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/ctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 6e6c1d1..0aa49ab 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -1367,7 +1367,7 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, et->texts = tplg_calloc(heap, sizeof(char *) * ec->items); if (!et->texts) return -ENOMEM; - for (i = 0; ec->items; i++) { + for (i = 0; i < ec->items; i++) { unsigned int j = i * sizeof(int) * ENUM_VAL_SIZE; et->texts[i] = ec->texts[i]; et->values[i] = (int *)&ec->values[j]; From patchwork Mon Aug 31 09:08:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 291913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4E72C433E2 for ; Mon, 31 Aug 2020 09:11:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 405DF208CA for ; Mon, 31 Aug 2020 09:11:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="tG5rNtLT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 405DF208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 77BC61812; Mon, 31 Aug 2020 11:10:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 77BC61812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865062; bh=dJl/Yz+/BWuFW+lTgl6wUJcsqYFTfa6BDSSbWreoYYs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tG5rNtLTPa497dN1L1/fxiuSBnsJv3JkNwty8GPT5lQA3Qw15oPcelZOV7/csq2cO eJ9AgNpQtofy1RFcW/K7+bQ3ct/IudZ1xrZgzLHg9P7e34S55vkMzb68B99rVxQ2Ns ZJUjNVxLwTWhQq+CHzlDuMR1U36569b1PEZIpK68= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 791FBF802E1; Mon, 31 Aug 2020 11:08:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 28FA8F802D2; Mon, 31 Aug 2020 11:08:21 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B6F6AF80058 for ; Mon, 31 Aug 2020 11:08:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B6F6AF80058 IronPort-SDR: qyUn3Jvtk7EbqeJX4AA9PrJ/PUIdLzlHudrsQ3pWXsYUS9OvFE0DgdTTLfAK3u9NaPJFvjt6wW LCEr8OrapUXg== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466747" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466747" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:07 -0700 IronPort-SDR: IYfgFZ6e+buIiEJk4LIZVQVMXRcK6ZjeSKLKY5go8DSjHUcxCR6Kjh6pwjzWpZyqD+TCUYYAGS XvqcxzmxmbIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286878" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:05 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 03/10] topology: decode: Remove decoding values for enum control Date: Mon, 31 Aug 2020 11:08:56 +0200 Message-Id: <1598864943-22883-4-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Values have no representation in standard ALSA configuration files, therefore there is no need to populate them. Also memory for values wasn't allocated which was causing undefined behaviour. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/ctl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 0aa49ab..02e482e 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -1367,11 +1367,8 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, et->texts = tplg_calloc(heap, sizeof(char *) * ec->items); if (!et->texts) return -ENOMEM; - for (i = 0; i < ec->items; i++) { - unsigned int j = i * sizeof(int) * ENUM_VAL_SIZE; + for (i = 0; i < ec->items; i++) et->texts[i] = ec->texts[i]; - et->values[i] = (int *)&ec->values[j]; - } } et->map = tplg_calloc(heap, sizeof(struct snd_tplg_channel_map_template)); From patchwork Mon Aug 31 09:08:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 291910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C646FC433E6 for ; Mon, 31 Aug 2020 09:14:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49796208CA for ; Mon, 31 Aug 2020 09:14:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="cjwKqVxH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49796208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 D55311731; Mon, 31 Aug 2020 11:13:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D55311731 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865274; bh=E2GJWqiJza5q4wgO2Xrylcyn2Z8PEhuLPkKoGHcP9MU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=cjwKqVxH9c0DRnB8YrnlRdL5zfggqezBXyOQ4ojlaMWtSMGoON1AoXqINy/Jn4AVF ZqQDR995h3x9LdzF+5gTyWKkuYhtDq3cA7iwSg+wB8gRXr+5aD6mTWxl71vWDgjd5i eJuL3TII3L6WzgdOb6z9P45yHZBkMnDRuOlAddso= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DB35FF80316; Mon, 31 Aug 2020 11:08:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 40463F80303; Mon, 31 Aug 2020 11:08:54 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 02C45F8024A for ; Mon, 31 Aug 2020 11:08:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 02C45F8024A IronPort-SDR: 1gvCLb1S6I2HKXS3zw0kl3GKY4nxHo5zTS+Ru47fCWS+JspWmqhHjAEEVHAKsGY3qr87R4boy7 QFhhfIQFZuYg== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466752" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466752" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:09 -0700 IronPort-SDR: uhKatnGQQJxbzwEtSiDt7BzelCucmBv+l6jyvLi3KRczeBbdQ96pTPd8NMn8bjjkXmUUKfnBp0 uY5wMOIFYoYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286884" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:07 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 04/10] topology: decode: Add enum control texts as separate element Date: Mon, 31 Aug 2020 11:08:57 +0200 Message-Id: <1598864943-22883-5-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Texts are separate sections that should referenced by enum control. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/ctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 02e482e..1f39846 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -1088,11 +1088,19 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, } if (enum_ctl->texts != NULL) { + struct tplg_elem *texts = tplg_elem_new_common(tplg, NULL, + enum_ctl->hdr.name, SND_TPLG_TYPE_TEXT); + + texts->texts->num_items = num_items; for (i = 0; i < num_items; i++) { - if (enum_ctl->texts[i] != NULL) - snd_strlcpy(ec->texts[i], enum_ctl->texts[i], - SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + if (!enum_ctl->texts[i]) + continue; + snd_strlcpy(ec->texts[i], enum_ctl->texts[i], + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); + snd_strlcpy(texts->texts->items[i], enum_ctl->texts[i], + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); } + tplg_ref_add(elem, SND_TPLG_TYPE_TEXT, enum_ctl->hdr.name); } if (enum_ctl->values != NULL) { From patchwork Mon Aug 31 09:08:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 251222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D0CAC433E6 for ; Mon, 31 Aug 2020 09:15:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B489D208CA for ; Mon, 31 Aug 2020 09:15:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="TUXH4mMr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B489D208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 35B81185C; Mon, 31 Aug 2020 11:14:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 35B81185C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865306; bh=tzp/yXwtZF0kN5xmenOHr54FeWLG2PtjI6ADqYkKvYY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TUXH4mMr+1ybozrZ0r8wgVHL0c6PWgUcrxNoAMZaxjQiE+zAPqE4Ey18UipEE8qEt 3mYMCXubTJ7B2o8BNkUdb6kz92f8ab2DR+XQEZRuP8K3eUYa+ra79d0rzxU95o0GNY 5LJj6/Oo1u59/u5ByPy5xrpu756oeCwtQeMHOn9Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DF5DAF80317; Mon, 31 Aug 2020 11:08:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 49EEFF80268; Mon, 31 Aug 2020 11:08:54 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3719BF80268 for ; Mon, 31 Aug 2020 11:08:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3719BF80268 IronPort-SDR: jmKUKdFWLrHgbMJXITJYxDZNQQ4Cs6VTxUaU1+liO2f9+DzVdCYP/G4+fFX4tknBL9tEyodiIT r9o0oI9Obing== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466761" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466761" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:11 -0700 IronPort-SDR: 35gDVmuE6YjP3cxtp1yM74AK7vvleT+aAGTI4AxSGYwQQbx4vJY+2M0/Asq2pkb2Kj2Xfv687Y Cl6lznWUl6Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286890" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:09 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 05/10] topology: decode: Fix printing texts section Date: Mon, 31 Aug 2020 11:08:58 +0200 Message-Id: <1598864943-22883-6-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topology/text.c b/src/topology/text.c index 507c545..b899b28 100644 --- a/src/topology/text.c +++ b/src/topology/text.c @@ -103,7 +103,7 @@ int tplg_save_text(snd_tplg_t *tplg ATTRIBUTE_UNUSED, return 0; err = tplg_save_printf(dst, pfx, "'%s'.values [\n", elem->id); for (i = 0; err >= 0 && i < texts->num_items; i++) - err = tplg_save_printf(dst, pfx, "\t'%s'\n", texts->items[i][0]); + err = tplg_save_printf(dst, pfx, "\t'%s'\n", texts->items[i]); if (err >= 0) err = tplg_save_printf(dst, pfx, "]\n"); return err; From patchwork Mon Aug 31 09:08:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 251225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2943EC433E2 for ; Mon, 31 Aug 2020 09:11:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F556208DB for ; Mon, 31 Aug 2020 09:11:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="u5h2EFVH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F556208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 E535F17DF; Mon, 31 Aug 2020 11:10:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E535F17DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865101; bh=aM11ciCeIs5wcpLDnfPDUnJUi6z7A4cBRtOd3Ix61Dw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=u5h2EFVHfRzE5I1rTus4xIUN4zdagjRFxp72wonb8zZDnPGsDsytMJhAaxKzUUOOD S21wm1GFYCYg/L9x4Y93pJKioEi0kNJXa+ea/h/EkKOFwLKQf9U4MQ98ScGC9gHcwn bvqmtSIJy4qCVPhx/IYGH7YlPFTNbwZDnaKIvy2Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CF363F802C3; Mon, 31 Aug 2020 11:08:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B69A3F80257; Mon, 31 Aug 2020 11:08:21 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DBFBFF80257 for ; Mon, 31 Aug 2020 11:08:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DBFBFF80257 IronPort-SDR: uriUJvDlBRKD57f6pvMFBs93Jhz7XyuewfWbsmVlrRGmzViGGPgaevS61Wi2jdkTPMiFX7TnzA RQ/68Fgkx6gg== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466765" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466765" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:12 -0700 IronPort-SDR: x48NpKKF30kTAHhKMxBwdlVLSUsggnfXDDGcXqYnsxVKMMLCuuKvNlnDAeThPkKqY0agjSBfTY BHddfYc3B2sQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286896" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:11 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 06/10] topology: decode: Change declaration of enum decoding function Date: Mon, 31 Aug 2020 11:08:59 +0200 Message-Id: <1598864943-22883-7-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Size constraints are always checked before invoking tplg_decode_control_enum1. There is no need to validate it twice. Alos moved debug print about size to invoking function, since now it's it responsibility to check size. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/ctl.c | 19 +++++-------------- src/topology/dapm.c | 3 +-- src/topology/tplg_local.h | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 1f39846..47db400 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -1335,22 +1335,10 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, struct list_head *heap, struct snd_tplg_enum_template *et, size_t pos, - void *bin, size_t size) + struct snd_soc_tplg_enum_control *ec) { - struct snd_soc_tplg_enum_control *ec = bin; int i; - if (size < sizeof(*ec)) { - SNDERR("enum: small size %d", size); - return -EINVAL; - } - - tplg_log(tplg, 'D', pos, "enum: size %d private size %d", - ec->size, ec->priv.size); - if (size != ec->size + ec->priv.size) { - SNDERR("enum: unexpected element size %d", size); - return -EINVAL; - } if (ec->num_channels > SND_TPLG_MAX_CHAN || ec->num_channels > SND_SOC_TPLG_MAX_CHAN) { SNDERR("enum: unexpected channel count %d", ec->num_channels); @@ -1427,7 +1415,10 @@ next: return -EINVAL; } - err = tplg_decode_control_enum1(tplg, &heap, &et, pos, bin, size); + tplg_log(tplg, 'D', pos, "enum: size %d private size %d", + ec->size, ec->priv.size); + + err = tplg_decode_control_enum1(tplg, &heap, &et, pos, ec); if (err >= 0) { t.enum_ctl = &et; err = snd_tplg_add_object(tplg, &t); diff --git a/src/topology/dapm.c b/src/topology/dapm.c index cd1a877..73a9390 100644 --- a/src/topology/dapm.c +++ b/src/topology/dapm.c @@ -972,8 +972,7 @@ next: err = -EINVAL; goto retval; } - err = tplg_decode_control_enum1(tplg, &heap, et, pos, - bin, size2); + err = tplg_decode_control_enum1(tplg, &heap, et, pos, ec); break; case SND_SOC_TPLG_TYPE_BYTES: bt = tplg_calloc(&heap, sizeof(*bt)); diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index 5ace0d1..acb01a8 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -398,7 +398,7 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, struct list_head *heap, struct snd_tplg_enum_template *et, size_t pos, - void *bin, size_t size); + struct snd_soc_tplg_enum_control *ec); int tplg_decode_control_enum(snd_tplg_t *tplg, size_t pos, struct snd_soc_tplg_hdr *hdr, void *bin, size_t size); From patchwork Mon Aug 31 09:09:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 291912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6854BC433E2 for ; Mon, 31 Aug 2020 09:12:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E1124214D8 for ; Mon, 31 Aug 2020 09:12:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="enhshmHR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1124214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 42C65184E; Mon, 31 Aug 2020 11:11:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 42C65184E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865143; bh=ApzChtk66UAKjl39ihxLNZA0AxcKtfhsHOjE7Ko1u0o=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=enhshmHR1//TMdQnkxGJ+CWQGWGgPlaPqKC5XOHllYv6hA1p7Iw4/Gn/Sj23uOdOA 9m5xnLTHy58KRw7+OUBKgew0Q1YKXyQLJ6vQFTQt+YH0vOMNiLD3h7e2Qge/9wH46l umb3fSrjoLQwIJo6BNoJ8jWawUSKtU0OknWAgrCU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F3B83F802E3; Mon, 31 Aug 2020 11:08:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2DC58F802E8; Mon, 31 Aug 2020 11:08:27 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0348BF802A1 for ; Mon, 31 Aug 2020 11:08:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0348BF802A1 IronPort-SDR: GzZDOE8gPcJgCoa6d4L5UKvZ6zGslq6ub+qUUTGG/eSMKZjMhIhq+wVl7Q9/NMhdf0x8ZHsbao nNvTbtwqDJfw== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466768" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466768" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:14 -0700 IronPort-SDR: m4XB9olji4b0eDuL6BKUB+qLVDHsE33BiQIXSb8GGjWrRTAyNimWn/xZYFsEC9tRvVoHdcTVRW ZC/6fG4JZTmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286901" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:13 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 07/10] topology: decode: Fix decoding PCM formats and rates Date: Mon, 31 Aug 2020 11:09:00 +0200 Message-Id: <1598864943-22883-8-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Not checking _LAST format and rate, which are valid indexes in arrays, makes data loss while converting binary to standard ALSA configuration file. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/topology/pcm.c b/src/topology/pcm.c index b15b950..db40114 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -549,7 +549,7 @@ int tplg_save_stream_caps(snd_tplg_t *tplg ATTRIBUTE_UNUSED, if (err >= 0 && sc->formats) { err = tplg_save_printf(dst, pfx, "\tformats '"); first = 1; - for (i = 0; err >= 0 && i < SND_PCM_FORMAT_LAST; i++) { + for (i = 0; err >= 0 && i <= SND_PCM_FORMAT_LAST; i++) { if (sc->formats & (1ULL << i)) { s = snd_pcm_format_name(i); err = tplg_save_printf(dst, NULL, "%s%s", @@ -563,7 +563,7 @@ int tplg_save_stream_caps(snd_tplg_t *tplg ATTRIBUTE_UNUSED, if (err >= 0 && sc->rates) { err = tplg_save_printf(dst, pfx, "\trates '"); first = 1; - for (i = 0; err >= 0 && i < SND_PCM_RATE_LAST; i++) { + for (i = 0; err >= 0 && i <= SND_PCM_RATE_LAST; i++) { if (sc->rates & (1ULL << i)) { s = get_rate_name(i); err = tplg_save_printf(dst, NULL, "%s%s", From patchwork Mon Aug 31 09:09:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 251224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97E86C2BB4D for ; Mon, 31 Aug 2020 09:12:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0FF8620EDD for ; Mon, 31 Aug 2020 09:12:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="NEdHlwNg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FF8620EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 F300917DF; Mon, 31 Aug 2020 11:11:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F300917DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865164; bh=ZitGseRUwx+m/0TwTJoxT0MKVD3dFi+PmSbqIJ+2sqs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NEdHlwNgFSxQcnTAZ3DoRthCklUKakS0J3zDeCwG/6uPScvlA5kS9NGP+SWBsxCxu d8S501axxw9xUuSL7pC6SdwIXERqm+iab9ulKdNlZG4vVO1SOnIsKgUtDFvB8s9onR pZl2QfooY+vCCuG8eSnFvRwbaU2flMZEUQjAnTC0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D56CFF802EC; Mon, 31 Aug 2020 11:08:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B2134F802A1; Mon, 31 Aug 2020 11:08:27 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DE1FEF802C3 for ; Mon, 31 Aug 2020 11:08:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DE1FEF802C3 IronPort-SDR: 4W1B6SXc/K2fm7zMdmL9y6g+dw3nwQIMD15kt6BsY09skHIZqlMUjAH/HquWCuUppoAVDyQQV8 ooKocnXI8wnQ== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466771" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466771" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:16 -0700 IronPort-SDR: j/l+E8Iw2ir4/VPY/FuIan9r+RL5yBvptoGGLQ/+WqyshCIub/eY+WSnMVIFUgPNAp6+TFkRJ4 1M8H0/5sFagA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286909" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:14 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 08/10] topology: decode: Print sig_bits field in PCM capabilities section Date: Mon, 31 Aug 2020 11:09:01 +0200 Message-Id: <1598864943-22883-9-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Not printing this field makes data loss while converting from binary to standard ALSA configuration file. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/pcm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/topology/pcm.c b/src/topology/pcm.c index db40114..49c5eab 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -604,6 +604,9 @@ int tplg_save_stream_caps(snd_tplg_t *tplg ATTRIBUTE_UNUSED, if (err >= 0 && sc->buffer_size_max) err = tplg_save_printf(dst, pfx, "\tbuffer_size_max %u\n", sc->buffer_size_max); + if (err >= 0 && sc->sig_bits) + err = tplg_save_printf(dst, pfx, "\tsig_bits %u\n", + sc->sig_bits); if (err >= 0) err = tplg_save_printf(dst, pfx, "}\n"); return err; From patchwork Mon Aug 31 09:09:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 251223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5BE6C433E2 for ; Mon, 31 Aug 2020 09:14:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63CFF208CA for ; Mon, 31 Aug 2020 09:14:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="BLaBu+T+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63CFF208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 E299C1849; Mon, 31 Aug 2020 11:13:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E299C1849 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865250; bh=4tipX2opyLWyj6zkYG9FErrSDcJh1xv5sk1B+NKnnp4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BLaBu+T+nLZz4vIKM/ij7fOUYUGF81AfFeov+EcnXtTdX49nf9M7vd9ArE+u8qb7S d9wYWBa3WFiwO9gakkolXaXr9t/nqNCpklm5IRyPebQDTOhRTDLXyJvyM2WCGbEBmZ VtdIiNnq1Q73863I4R0PT8QeuwGE07/+Ex2XhTEk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 96C79F80306; Mon, 31 Aug 2020 11:08:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA639F802E9; Mon, 31 Aug 2020 11:08:32 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9CD03F802BC for ; Mon, 31 Aug 2020 11:08:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9CD03F802BC IronPort-SDR: 5h3ugySDcVJv2EXfOZIcKJnfP2/N/1CxJNrLiFuozyvvK/BME81U4lEVBlrj4ENybnxZkbJFci fwd91TFrv0Aw== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466780" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466780" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:18 -0700 IronPort-SDR: cRh4TV9tHBkv1spdWoRZ6eqOqGKHpmCwr2YYs8yim8IWA4yPaKX/TRJ2D2X1Le2Pxsxu55LqoA qykD1yp3295A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286937" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:16 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 09/10] topology: decode: Add DAI name printing Date: Mon, 31 Aug 2020 11:09:02 +0200 Message-Id: <1598864943-22883-10-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" DAI name is a part of topology binary. Not printing makes data loss while converting from binary to standard ALSA configuration file. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/topology/pcm.c b/src/topology/pcm.c index 49c5eab..5a54e15 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -781,7 +781,9 @@ int tplg_save_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED, struct snd_soc_tplg_pcm *pcm = elem->pcm; int err = 0; - if (pcm->dai_id > 0) + if (strlen(pcm->dai_name)) + err = tplg_save_printf(dst, pfx, "dai.'%s'.id %u\n", pcm->dai_name, pcm->dai_id); + else if (pcm->dai_id > 0) err = tplg_save_printf(dst, pfx, "dai.0.id %u\n", pcm->dai_id); return err; } From patchwork Mon Aug 31 09:09:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 291911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86E39C433E2 for ; Mon, 31 Aug 2020 09:13:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 101672100A for ; Mon, 31 Aug 2020 09:13:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="oc5FHu3u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 101672100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 595101861; Mon, 31 Aug 2020 11:12:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 595101861 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865200; bh=D3PlPG7gV6yHwlS8euLBulPj9X3Rb09FdnJHmaMU3dI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oc5FHu3uI5djBnpjekWcgKl7CM/lDz8ada7EbeyecphblYiXGu9Yj0duNPd+fXHU8 pWh2psUpo+XniFNEHdkSjv7KIw9YcsXH2yQ7brO0UHva5I7o9l/5YNatHxr0v7MvBv kaQeGmI2vtkOoFozFsIgT61gb+Akav7ct9hoynBU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D479BF802FB; Mon, 31 Aug 2020 11:08:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71207F802EA; Mon, 31 Aug 2020 11:08:30 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 611B5F8026F for ; Mon, 31 Aug 2020 11:08:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 611B5F8026F IronPort-SDR: V8lsuoFyIvPLXkatYjrXQ0bccFPtnQbE91rcJ+1yEl06asNwHXf577Ar1oPXMQJ/+CJuLjjcPJ WEGfwmk0mjcQ== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="136466783" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="136466783" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:19 -0700 IronPort-SDR: gozAWbBfCOt95Er7Bfi2b3CKNdSZJMQxSxaRiwUCRS7HJWI5z3Lgd1ckeehtJ3yfxlkFvg0XdJ jozznpWlYVcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="314286961" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2020 02:08:18 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v4 10/10] topology: Make buffer for saving dynamic size Date: Mon, 31 Aug 2020 11:09:03 +0200 Message-Id: <1598864943-22883-11-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1598864943-22883-1-git-send-email-piotrx.maziarz@linux.intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, cezary.rojewski@intel.com, amadeuszx.slawinski@linux.intel.com, tiwai@suse.com 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" Some fields can exceed size limit, e.g. private data has no size restriction. Therefore it needs to be dynamically increased. Signed-off-by: Piotr Maziarz Reviewed-by: Cezary Rojewski Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart --- src/topology/save.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/topology/save.c b/src/topology/save.c index 4ecf86c..9c74735 100644 --- a/src/topology/save.c +++ b/src/topology/save.c @@ -19,22 +19,43 @@ #include "tplg_local.h" #define SAVE_ALLOC_SHIFT (13) /* 8192 bytes */ +#define PRINT_BUF_SIZE (1024) +#define PRINT_BUF_SIZE_MAX (1024 * 1024) int tplg_save_printf(char **dst, const char *pfx, const char *fmt, ...) { va_list va; - char buf[1024], *s; + char *buf, *s; size_t n, l, t, pl; + int ret = 0; + + buf = malloc(PRINT_BUF_SIZE); + if (!buf) + return -ENOMEM; if (pfx == NULL) pfx = ""; va_start(va, fmt); - n = vsnprintf(buf, sizeof(buf), fmt, va); + n = vsnprintf(buf, PRINT_BUF_SIZE, fmt, va); va_end(va); - if (n >= sizeof(buf)) - return -EOVERFLOW; + if (n >= PRINT_BUF_SIZE_MAX) { + ret = -EOVERFLOW; + goto end; + } + + if (n >= PRINT_BUF_SIZE) { + char *tmp = realloc(buf, n + 1); + if (!tmp) { + ret = -ENOMEM; + goto end; + } + buf = tmp; + va_start(va, fmt); + n = vsnprintf(buf, n + 1, fmt, va); + va_end(va); + } pl = strlen(pfx); l = *dst ? strlen(*dst) : 0; @@ -47,7 +68,8 @@ int tplg_save_printf(char **dst, const char *pfx, const char *fmt, ...) if (s == NULL) { free(*dst); *dst = NULL; - return -ENOMEM; + ret = -ENOMEM; + goto end; } } else { s = *dst; @@ -57,6 +79,8 @@ int tplg_save_printf(char **dst, const char *pfx, const char *fmt, ...) strcpy(s + l, pfx); strcpy(s + l + pl, buf); *dst = s; +end: + free(buf); return 0; }