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: 11745953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DCBE13B6 for ; Mon, 31 Aug 2020 09:09:56 +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 C777A208CA for ; Mon, 31 Aug 2020 09:09:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="gntLXOSP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C777A208CA 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 467A61820; Mon, 31 Aug 2020 11:09:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 467A61820 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598864994; 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=gntLXOSPdRptkd/zEiN+wsFkwN12uu9RHP7ur7KUoczlmn3q1IB7IaQyb0U6LNeq+ 4uhdJgA8tsMPVzQqDmwhybSnMRG42Cmk1LMnH1DBOt7+23fnF9UQ6m5LrN+wiPbv5u dWYcYMxTot1TrGk1hmIfLMDLh3fCO1J0n9KCK9Tk= 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) 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 8B63AF80146; Mon, 31 Aug 2020 11:08:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36F6813B6 for ; Mon, 31 Aug 2020 09:10: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 BE767208CA for ; Mon, 31 Aug 2020 09:10: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="qYIYurvQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE767208CA 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 214621823; Mon, 31 Aug 2020 11:09:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 214621823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865041; 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=qYIYurvQsnr1E2DXLrkVikvR+Iv3MFLlOXWxv9aYWZ0iEHY0695ZHVEhDYSQEBYH1 pXWfP/pg07FfGbAy9Rnl5wYOEdM43X8gmPG6QkpEu8UbxR37EOvKUKll7Rpzc703BB CrXjbRDUTmtNnJOCtpWI51xHKMnCGQpr31Jmw5eU= 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) 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 D56A1F802D2; Mon, 31 Aug 2020 11:08:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98E3C13B6 for ; Mon, 31 Aug 2020 09:11:17 +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 2D807208CA for ; Mon, 31 Aug 2020 09:11:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="bf3//j3Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D807208CA 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 C00CF182B; Mon, 31 Aug 2020 11:10:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C00CF182B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865074; 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=bf3//j3ZoODipGi8Ni+7nYm8XEB+vWPD08hG88+nm1D2Lv1vxHL3DwPnswDL7qWyM v9dQKWZ6SskpuDUzp9xFPkCazcKbV6WSLAkx0WPPVPwHdlO5qeYgVXyNQ245P/DA2f NrHXB7dXT0yuSJefnEZyWx7iYCzpRHDzQF/YmoZM= 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) 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 28FA8F802D2; Mon, 31 Aug 2020 11:08:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9FC913B6 for ; Mon, 31 Aug 2020 09:14:33 +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 66258208CA for ; Mon, 31 Aug 2020 09:14:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="SQNHCUpv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66258208CA 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 C4B781852; Mon, 31 Aug 2020 11:13:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C4B781852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865271; 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=SQNHCUpv1tAeDvBvrldBm1ZAMfeMTI9ru5KTLpWD4hiG7kaEbtlbp0Zuvo9ZqQZK0 5TO8WWBO1OSVItjdaCAAPPW9ZNQzi+1G8oycT/yy5/J07/RfG09HLGnGca40bIvCjn jbbneME+K7AMEYuijVyB8fAvfJo2xMyW1bk84k0k= 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) 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 40463F80303; Mon, 31 Aug 2020 11:08:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745991 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FF2A13B6 for ; Mon, 31 Aug 2020 09:15: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 2AF97208CA for ; Mon, 31 Aug 2020 09:15:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="EYowLOZy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AF97208CA 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 A00A11870; Mon, 31 Aug 2020 11:14:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A00A11870 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865300; 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=EYowLOZyN64egKScgMnMhzB4IfgzNVuUnBn5k/tE9LoWcldIeBKn5kEJgIE1cyf1k Rge89Lcifr1NuRCQQVsUIQ557baySZiw0eLbzeuxyoQTo74bOtvhn4L646gh7Ru72f UycK4K3nitnDztHI5S+jR3ricwSVqv6dGK+dzH/A= 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) 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 49EEFF80268; Mon, 31 Aug 2020 11:08:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48BA413B6 for ; Mon, 31 Aug 2020 09:11:37 +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 D4105208DB for ; Mon, 31 Aug 2020 09:11: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="aRlLbbcO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4105208DB 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 254741844; Mon, 31 Aug 2020 11:10:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 254741844 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865095; 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=aRlLbbcOhTIT9tPbKoSFZ3dEjv1Y9mShrJhqNWzs0zOqRRlq/ne9JnPxhjAFHiiRr yuObAUeONZQUcBwuT6vDnRhURUXxTSWXH9oDQs28PB1Aq4X1Yu4mgIeIWhRDE3JonS yuJ2fs5yl5aA36Su7RX2ftEpYwethC2H+cg/sfWY= 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) 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 B69A3F80257; Mon, 31 Aug 2020 11:08:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C2C813B6 for ; Mon, 31 Aug 2020 09:12:19 +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 C6B8320936 for ; Mon, 31 Aug 2020 09:12:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="q26zoWgI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6B8320936 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 382091849; Mon, 31 Aug 2020 11:11:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 382091849 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865137; 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=q26zoWgIsT5vMybKVYV8QaYWihjlRIFj8pJOEmQgIsOgQvl2+iG2E18NNkG6oafBt h4oVomWESal520y/mYN90GK20GDXHz9886FOU5eXooBXUYtMJlJi77+kVSbkrSE22W w0eEVEmkVXOzEA4o7MhQIZNgjg+8nes69gGZOQtQ= 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) 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 2DC58F802E8; Mon, 31 Aug 2020 11:08:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A7A71667 for ; Mon, 31 Aug 2020 09:12:41 +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 E713F208CA for ; Mon, 31 Aug 2020 09:12:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="MbQXhT0W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E713F208CA 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 4D4131860; Mon, 31 Aug 2020 11:11:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4D4131860 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865159; 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=MbQXhT0Wfcd/kx1857pFdHEtvwcv/pPbrCHvnbKs3NrIrPGBSiDhBKIQbDQSiR5ce QMtZnxVH1vwxQBho7nYsmVuEIylHAiKj2mdeStIkjiaZH0WrePmdXLllcUIfd5sZxe H8TQTsRJVo8PBbu8MKkmFI8naS9/aoprN/rqHhjU= 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) 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 B2134F802A1; Mon, 31 Aug 2020 11:08:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745987 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6425A13B6 for ; Mon, 31 Aug 2020 09:14:06 +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 E0B4B208CA for ; Mon, 31 Aug 2020 09:14:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Um8hYAu/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0B4B208CA 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 62DC11810; Mon, 31 Aug 2020 11:13:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 62DC11810 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865244; 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=Um8hYAu/oyqskQ6fPwZLgPZoD+BIAyToAj3/M27IMWXFbfpHug3o7y9HsvGpq2g2S MxJpe7fwpp0EjnX6dVbxYMJI30FB11HYXa4I1rb1l2Uf2HQadWUWemMX1aCHYOr70b 8uHurqk04kGSODG/qBm0B8QawWNEGRveGW7fP7ww= 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) 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 BA639F802E9; Mon, 31 Aug 2020 11:08:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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: 11745985 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D92F13B6 for ; Mon, 31 Aug 2020 09:13:18 +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 032802098B for ; Mon, 31 Aug 2020 09:13:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="bD6Ljm10" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 032802098B 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 2512B1814; Mon, 31 Aug 2020 11:12:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2512B1814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1598865196; 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=bD6Ljm10tg0GXneTzycYClNw5UhEQILSrP+JNCWjtPyS9iFndlV+D6gOPT7MtSuRw 4Ikx22vZDfvFpqXmhgnCpEUnnkKmt24q7ijY0+DpGqh51G4inlye9ZSh/vb6PiGfH+ xADhNZ+XM+j0DFi+6ulTUPoX5nLrREYaYvhjjVJY= 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) 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 71207F802EA; Mon, 31 Aug 2020 11:08:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 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; }