From patchwork Mon Jul 6 09:05:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645355 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 8469C14DD for ; Mon, 6 Jul 2020 10:11:03 +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 18D1020739 for ; Mon, 6 Jul 2020 10:11:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="ah0pXD2a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18D1020739 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 8777D1685; Mon, 6 Jul 2020 12:10:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8777D1685 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030261; bh=brP1UFdcHs4IjhyEsfzAHgzlq6CNmu70NsleAD1TNYM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ah0pXD2a+V00vcz14Z+LqhhtW0UBrbl7ybYiv0tFXIYdDtMAnddYq67PRHD59EGR4 I8ut512uCoRVwJuTohTxUKdWQ7tfO+t5dsDwWnj6iRo0ILp7TfG22pebF8vcr2KUEn DB5TSjtj7Yn4YHyaWtBPRh/4ndu7tBOnAGvl84rI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 02CF4F802DB; Mon, 6 Jul 2020 12:07:48 +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 3A93AF802A0; Mon, 6 Jul 2020 12:07:42 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 C75EAF8011F for ; Mon, 6 Jul 2020 12:07:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C75EAF8011F IronPort-SDR: ntYwo/dT0WLFWe+mxKJMIZVI72jchIlJeWvMJFII3XsgcA3swpmzWWTkkTzzIpttm6HocmV/oB ZJAUhw2TOISQ== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637959" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637959" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:32 -0700 IronPort-SDR: eCq9XNLWiLBIZ9HBUI9S9xKQ0o9OcAJm50yzQmqPr8lDTOVEcoxxrBIJn4z+7w0io1MZLeGE1H xO6UY0GRj/fQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313912984" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:31 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 01/10] topology: decode: Fix channel map memory allocation Date: Mon, 6 Jul 2020 11:05:54 +0200 Message-Id: <1594026363-30276-2-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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. Change-Id: Iac0bfe7dabfd59494b78afba17cf2d3e0b429fef Signed-off-by: Piotr Maziarz --- 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 Jul 6 09:05:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645341 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 8E11E739 for ; Mon, 6 Jul 2020 10:09: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 1BB1B20739 for ; Mon, 6 Jul 2020 10:09: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="BPE1Lcy4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BB1B20739 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 AA3F91677; Mon, 6 Jul 2020 12:08:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AA3F91677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030160; bh=CCmwh3KEH9oxpyf6AYKRsjIPTDLo9Ww2T923lwD00s0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BPE1Lcy4cCelL9wsdRRErzD0MIWBfpcaesjMNin3JPrQQ9wDTnvBmdXY8Ju8MF6YB VlTpIqaBZR8zgrHmKKwJ+HOfbw2AodbauNhh1c5wqU+tgD8jvUVGOkVohhK/F7O0GR Yv4E9ODRFH2DB7FzwkzU65mgbQw25WUnCb1v0vjw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DCEEDF8027C; Mon, 6 Jul 2020 12:07:42 +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 B2CE3F80161; Mon, 6 Jul 2020 12:07:39 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 8CE26F80150 for ; Mon, 6 Jul 2020 12:07:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8CE26F80150 IronPort-SDR: /vxFELzwTekQ+42JlCPj9dJy7DHiZFDsPMqJUKVr1HvAYzpZaQjOL9oM65XXcGGsaAz3z12vbL JRBSO8Fs0FRg== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637961" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637961" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:34 -0700 IronPort-SDR: NMkuNHvtonQZPZMyxHer2HEP5Zzw5zzHzJtMVgl2+zK+S1tsW/nzC5unNZDrL5+GQKoMsS7KE1 5eOKd9rIXnMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313912991" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:32 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 02/10] topology: decode: Fix infinite loop in decoding enum control Date: Mon, 6 Jul 2020 11:05:55 +0200 Message-Id: <1594026363-30276-3-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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. Change-Id: Ide6b4d0e6ee7801bb7185e286be5d2fbf29695a6 --- 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 Jul 6 09:05:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645347 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 9AC3814DD for ; Mon, 6 Jul 2020 10:10: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 31CFE20739 for ; Mon, 6 Jul 2020 10:10: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="Q05b462T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31CFE20739 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 0C81F1684; Mon, 6 Jul 2020 12:09:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0C81F1684 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030209; bh=T/xanlNEuTTonvtvb2U4+LI7LPBI2xUYSv+qe2PzvHo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Q05b462T/fn6wWCDRp1Lcb8xZU8I9JpFl/V3GQ46DFyLJAy1b1ZS21OMOEVEloa54 fcKe1Mn3hQUX4kRT4WJJ1BCaKL1O/XuanQA81Upy/yu7gB+7zyvTZ7JhiQbaAS5IIH wwlHUB+oHCpg2BaJFGQGWjsUru9pXPkYpn134T6w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2817FF802BC; Mon, 6 Jul 2020 12:07:44 +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 E9ABCF802A0; Mon, 6 Jul 2020 12:07:40 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 3FA9EF8015C for ; Mon, 6 Jul 2020 12:07:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3FA9EF8015C IronPort-SDR: QshCA7UNL6xdGfM5WLlFu36dRqFbVRqIFoNkSDsTtROg+kA8C6KBaJZiyM1BcJkzMLMASbexje PbIDsOn0Rrpg== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637962" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637962" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:35 -0700 IronPort-SDR: xjrdLASryMolo3tWccF9DPC06AA/5uvQjbLrmLleUCXyC/G2Mo9i0q5Ps3DJh0SfxtOl1htd0b m8xB0P0etpLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313912996" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:34 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 03/10] topology: decode: Remove decoding values for enum control Date: Mon, 6 Jul 2020 11:05:56 +0200 Message-Id: <1594026363-30276-4-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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 UCM file, therefore there is no need to populate them. Also memory for values wasn't allocated which was causing undefined behaviour. Change-Id: I86b990d20808091eb61fb6710b35a0c1f1cbce10 --- 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 Jul 6 09:05:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645353 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 3C79214E3 for ; Mon, 6 Jul 2020 10:10: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 C77FD20739 for ; Mon, 6 Jul 2020 10:10:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Pkhoazj0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C77FD20739 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 4ECD5166C; Mon, 6 Jul 2020 12:09:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4ECD5166C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030244; bh=svBquMVvJXTKFFIyNUXxMQlYm19BBb4SYqNtjZP7PjI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Pkhoazj0NBsEuorj5DI83l+FDIOG8X7gYhyfbYzEwdT/kzyZomF+NbvBNkPgIg2qp lKPfkbcGsZDwnjPt2MtTSY8N4ctqXQQuAQBmL0EH7Z74gBntvngvciakAMz2KAaRY2 3/s2aSunJd9i3InhvZeORyajfN3TV+em0Q0QzF+c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 114E7F801D8; Mon, 6 Jul 2020 12:07:47 +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 C85C5F802A0; Mon, 6 Jul 2020 12:07:41 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 B4E3CF80125 for ; Mon, 6 Jul 2020 12:07:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B4E3CF80125 IronPort-SDR: 6gxx6NXXyb5ydjc6p0J423cZnVkYN3uhXPqFOaJWNEDll+kO4mq1GisgQY6iu+Ga03+pNVKYKc gXaMVjNrmWgQ== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637965" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637965" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:37 -0700 IronPort-SDR: 6w777GSf3RPmvUZjU+2kZujlJUKEZ/Y32lQasy2JOe58RISU2oawLITaRFuvWy77gxZ/XyZjHY Xmfvyo3g+3XA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913004" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:35 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 04/10] topology: decode: Add enum control texts as separate element Date: Mon, 6 Jul 2020 11:05:57 +0200 Message-Id: <1594026363-30276-5-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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. Change-Id: I7b97803da13478c642d003b78ce12be1eedbf802 --- 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 Jul 6 09:05:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645357 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 C83CB739 for ; Mon, 6 Jul 2020 10:11:48 +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 559BB20739 for ; Mon, 6 Jul 2020 10:11: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="isqWauWw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 559BB20739 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 DB9F11675; Mon, 6 Jul 2020 12:10:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB9F11675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030306; bh=DBjE0IkCKMsNzIza9NTZeeepT03hTlNwXbTXrFOgWGc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=isqWauWwvSUdbEafm++M2lA0Y2k9Cfd2qpPJu+dU/2fMjuWtzJldqOdJ+k5/9+e4p JNYxdQke5BctiTACMfJy0IkjAFf+hO9mxW7f4Tzayc4S4Nc9j1aznYfxHJEB0yksS0 kHkKrNb+p8rFsNqRLotKh3HrRwf6F5XcivaNm8wI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8E26BF802E1; Mon, 6 Jul 2020 12:07:49 +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 8A287F8027C; Mon, 6 Jul 2020 12:07:42 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 CDC32F8015A for ; Mon, 6 Jul 2020 12:07:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CDC32F8015A IronPort-SDR: cXz9/jE2qI66egOidk70+t8nGerFzvdKOBeoGHdHYJoJQvku6zz4H3XEIKJ3bhTazYgzWQwtfi IMLdrkCVwJ+A== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637966" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637966" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:38 -0700 IronPort-SDR: rzvKcWazLe5A66xWajnc079EUZTuKVoYRuVmxSZBPqM2oDF63PxdbVaeIfvVRHoHmprXSsQOYu pCiPhX6v9DsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913013" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:37 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 05/10] topology: decode: Fix printing texts section Date: Mon, 6 Jul 2020 11:05:58 +0200 Message-Id: <1594026363-30276-6-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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" Change-Id: Ie00ca47b18f527140b63b8c31e948f8850dfe11f --- 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 Jul 6 09:05:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645361 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 60E9A14DD for ; Mon, 6 Jul 2020 10:12:21 +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 EA5662075B for ; Mon, 6 Jul 2020 10:12:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="e3ZJeKuK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA5662075B 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 73A18167B; Mon, 6 Jul 2020 12:11:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 73A18167B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030339; bh=4KTV4U6hh7pQmAvILs89YAUbq1gaDgND7Hp3r9xR/LE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=e3ZJeKuKIkkhUctYt5krDOxsswMHlbLBlX0GnhkoNOU+2KbTtNMT/IkOV2Y1xRhbV T+I2zmUfpraTod2jHFz71SNG/2sHmfDuBJP5GcqDxGuE3h5qkSD8qSwzbLelohQDOc evhM2cisxQdqkBgBCwpQgnb/hNvjYrC5LI5XZRGw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 64A6FF802E2; Mon, 6 Jul 2020 12:07:50 +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 397D1F802BE; Mon, 6 Jul 2020 12:07:44 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 CF09AF80125 for ; Mon, 6 Jul 2020 12:07:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CF09AF80125 IronPort-SDR: JzHKlL3JFiZf8nl4RvHW3pBuGEwPGuUJIFDxy1KHH4/4pq2j5jnBbPHjAGNCHqNfpqBAF5clJL bIxhg/C43MXA== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637969" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637969" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:39 -0700 IronPort-SDR: gfDii5dcIpEJZAKSAB1CYCU0NJD08zAaWBTBTWA3yuJ0a+puwkBVRElP9NVrVo7yzCEGAAv8Ek EHCToOJG3h0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913019" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:38 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 06/10] topology: decode: Change declaration of enum decoding function Date: Mon, 6 Jul 2020 11:05:59 +0200 Message-Id: <1594026363-30276-7-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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. Change-Id: I8bdd93cb1534ae9217aee87cb2b267e175aa483f --- 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 Jul 6 09:06:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645367 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 7102D14DD for ; Mon, 6 Jul 2020 10:12:45 +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 F286A2075B for ; Mon, 6 Jul 2020 10:12:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="bjg4VKA9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F286A2075B 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 549F51686; Mon, 6 Jul 2020 12:11:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 549F51686 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030363; bh=rWtqJvbUeiP86JbImJ7QFSyPWgixsZFwlf3KUB5C0Oo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bjg4VKA9QHGHRPvIUe5fJgfeVT8rPXN0rsJFli2D4tH9/yk6XefqKLyPQZrDq6M1r fEXa+EDS3X1GVOn/Gag0yQRTJ+Usv/3kgVcBRDZ8oO2GmNM9zwRQUBe/12OEKSXEYV WTGL4wwVMldlbPwAo3s3XtoULywqMTjqvMbLRtbI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6E3D3F80125; Mon, 6 Jul 2020 12:07: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 16F02F802C2; Mon, 6 Jul 2020 12:07:45 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 D0521F801D8 for ; Mon, 6 Jul 2020 12:07:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D0521F801D8 IronPort-SDR: J5ePQtRB87NzSIvHB4xeXTT6LCo14r49PSmJLExcf7NjLoSgUgjWNV520IDa+Th5y0ebGyFeML GQJTYDjXfWXA== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637972" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637972" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:41 -0700 IronPort-SDR: ACksTtTBLkJiNMti9FChuwV4E+0PlMr7R7WL3Mh05rV59q4LPUcP+KUE7Nw/tk9JzfCcqVWbsM SMohfJ5kvl1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913024" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:40 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 07/10] topology: decode: Fix decoding PCM formats and rates Date: Mon, 6 Jul 2020 11:06:00 +0200 Message-Id: <1594026363-30276-8-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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 UCM. Change-Id: I71ac42b65e8b1d79f2a061f805c62e29a758ad74 --- 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 Jul 6 09:06:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645371 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 59023739 for ; Mon, 6 Jul 2020 10:13:27 +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 E3F0D2075B for ; Mon, 6 Jul 2020 10:13:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="CHEUwmbu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3F0D2075B 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 63FA81663; Mon, 6 Jul 2020 12:12:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 63FA81663 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030405; bh=seMRuYxVxpZj7CNWBcGa8BSDDKXiKa0anYuj/R3Gn+0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CHEUwmbuQlTen6ZZkuzip02XJl0tW4zlWvpkTp2p4aFvEnnFTuwjlkBMWcyIvB/aU F7MwAsA+ieSKmNvDyfS0sCgYhHxv79ZKTNshOzXsA5iQ/XcHFzcsaZWTcMF+nUrgSQ BJdA+tz7J3AEY47dBG++VVq0gf80lqrgrbNTugIU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5D3F2F802EC; Mon, 6 Jul 2020 12:07: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 259F2F802C4; Mon, 6 Jul 2020 12:07:46 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 44E1CF802A9 for ; Mon, 6 Jul 2020 12:07:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 44E1CF802A9 IronPort-SDR: KAY1u95eU7S4P7GnrEQBfctpuBnLS0cEZsisdzhhll5U/zslp2eOleDNXKbhVMcBRboHmdCxZC 6ArwbwMG3t0A== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637974" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637974" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:42 -0700 IronPort-SDR: azDzqQMqgE6eGwshya/CZig4dZ5J14QW5pLCijkHXdKbI+yhbk5ZuPKFUtMEaioYRVELxptYN5 pb2TZwntsCCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913033" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:41 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 08/10] topology: decode: Print sig_bits field in PCM capabilities section Date: Mon, 6 Jul 2020 11:06:01 +0200 Message-Id: <1594026363-30276-9-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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 UCM. Change-Id: Idba0c8bb537e7fc8af78f697781032005fa78d63 --- 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 Jul 6 09:06:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645381 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 6AF48739 for ; Mon, 6 Jul 2020 10:14:35 +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 02B2220760 for ; Mon, 6 Jul 2020 10:14:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="kCGgH5SV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02B2220760 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 8B4D81678; Mon, 6 Jul 2020 12:13:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8B4D81678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030473; bh=EzKVS1WST4ATVLY8ixzGQxiWpuU4uP96t/suRRtmyNU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kCGgH5SVQL5fAQwb1W/qFEyb/IyJUd9g5miwMC4TsMqLRDNWtl5wdCPNWx6AqWY5S dDGdpNzyjscFMoWDw2Nu6y5cEhXNXoKXsPsPK3e7QsKv8szy2R7k43rtxvINK+z4A7 Gnpm9f/cN10yowLwt+NCPXqBxP1xvlZgMscckQs8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 47062F80316; Mon, 6 Jul 2020 12:07: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 5BF68F802F7; Mon, 6 Jul 2020 12:07:51 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 B2BBFF80125 for ; Mon, 6 Jul 2020 12:07:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2BBFF80125 IronPort-SDR: 4rfLHY4ebj4mgyxfMXlz5A12QvyNY076Y2GkWUtxdSisLhIu7KNef2ZXGWhjBFoiFH/v99by0W 3LiQ72HljNAA== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637975" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637975" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:44 -0700 IronPort-SDR: mGophpnQgsVHtNuwWFnpdmrB7TrCLPVgva+niAWFKcoxGXPab9Wj0roJUCbbd7TNVZYNjpbV/q bSOmILmj7SmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913042" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:43 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 09/10] topology: decode: Add DAI name printing Date: Mon, 6 Jul 2020 11:06:02 +0200 Message-Id: <1594026363-30276-10-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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 UCM. Change-Id: I57307108b5e922d18db2f155b9237db3fe175d7f --- 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 Jul 6 09:06:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Maziarz X-Patchwork-Id: 11645373 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 3A4B214DD for ; Mon, 6 Jul 2020 10:14:10 +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 C4F452075B for ; Mon, 6 Jul 2020 10:14:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="G/vo83Ln" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4F452075B 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 5FB6A1677; Mon, 6 Jul 2020 12:13:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5FB6A1677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1594030448; bh=0ZHV4pvsMvPkVSlGEvzV6oF0tH2NyWaiE+diYMccbYI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=G/vo83Ln6KYg3JqABP85nyYhwDgopgkQwRNb1e48G52g26reEVZNSRb0ZSu9u5yjZ oMKXcN9CUdSU94F9Z1rKqQTDeAGRnBHjkReVIcQNW0Rykmna++ETB66Lvyy2uu/rUs ZfE5oXCmlYbUlUmqUOG/GmVncMrZ3/9rzY5s4lXM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1E053F80308; Mon, 6 Jul 2020 12:07:54 +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 F3C4AF802E1; Mon, 6 Jul 2020 12:07:48 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 EFF45F802A9 for ; Mon, 6 Jul 2020 12:07:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EFF45F802A9 IronPort-SDR: lRukALzWDlC/MD8oFj3xGJcnQYWouCtcgrxzXs6D4y5nlnWFhIBiDR8fxfVm/f6Cp2A3lWoJpW 13Z0C6+zrtWQ== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="135637977" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="135637977" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 03:07:45 -0700 IronPort-SDR: BCPE4rHmVdiVXg0k5Y925wfbfC8PwxoABI0/AvT3cCYNPjan4U5tfoZEBa+HxLP2toJkSc9j4O 3YwRabTEW6Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="313913049" Received: from test-hp-compaq-8100-elite-cmt-pc.igk.intel.com ([10.237.149.93]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 03:07:44 -0700 From: Piotr Maziarz To: alsa-devel@alsa-project.org Subject: [PATCH v2 10/10] topology: Make buffer for saving dynamic size Date: Mon, 6 Jul 2020 11:06:03 +0200 Message-Id: <1594026363-30276-11-git-send-email-piotrx.maziarz@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> References: <1594026363-30276-1-git-send-email-piotrx.maziarz@linux.intel.com> Cc: cezary.rojewski@intel.com, amadeuszx.slawinski@intel.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. Change-Id: Ie274fd304eba5d600e198f4febbc6216f01b57e1 --- 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; }