From patchwork Wed Aug 21 21:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaska Uimonen X-Patchwork-Id: 11108197 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 B8B8914DB for ; Wed, 21 Aug 2019 21:23: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 D02AE2332A for ; Wed, 21 Aug 2019 21:23:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="OI/B/dX+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D02AE2332A 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 C301586F; Wed, 21 Aug 2019 23:22:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C301586F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1566422621; bh=LUkGY63Saao6Ct9nLJNwaJNwbCzAWEkpxycxnjOQNrI=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=OI/B/dX+Hc0bDxQkMTRqvZnSVgFea3dfz5ZKIfAUxwNQivivMl9JVWhu3EQ5XkXUG Mz8j5sMu6YdT2AXbpBW8PJkbzz9nlMA37waBFmDgd8Rc3PIPJLhWRTA5cJWeWa3ALe S8eXHnIgIwH5Gtd7ekOFTTqYufNsbzk0DvVIPsE4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 082E8F802E0; Wed, 21 Aug 2019 23:22: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 4BEFCF80306; Wed, 21 Aug 2019 23:22:49 +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_NONE,SPF_NONE, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 F25E0F802E0 for ; Wed, 21 Aug 2019 23:22:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F25E0F802E0 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2019 14:22:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,414,1559545200"; d="scan'208";a="190342290" Received: from kekkonen.fi.intel.com ([10.237.72.156]) by orsmga002.jf.intel.com with ESMTP; 21 Aug 2019 14:22:41 -0700 From: Jaska Uimonen To: alsa-devel@alsa-project.org Date: Thu, 22 Aug 2019 00:11:38 +0300 Message-Id: <20190821211138.14618-1-jaska.uimonen@linux.intel.com> X-Mailer: git-send-email 2.13.6 Cc: Jaska Uimonen , broonie@kernel.org Subject: [alsa-devel] [PATCH v2] ASoC: SOF: topology: fix get control data return type and arguments 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Jaska Uimonen sof_get_control_data returns negative values even though the return value is defined unsigned (size_t). So change the return value type to int and add the data size as pointer argument to sof_get_control_data to avoid ambiquity in the meaning of the return type. Fixes: cac974a51ebb ("ASoC: SOF: topology: use set_get_data in process load") Reported by: Dan Carpenter Signed-off-by: Jaska Uimonen --- sound/soc/sof/topology.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 28a7a6e06a53..fc85efbad378 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1752,17 +1752,19 @@ static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index, return ret; } -static size_t sof_get_control_data(struct snd_sof_dev *sdev, - struct snd_soc_dapm_widget *widget, - struct sof_widget_data *wdata) +static int sof_get_control_data(struct snd_sof_dev *sdev, + struct snd_soc_dapm_widget *widget, + struct sof_widget_data *wdata, + size_t *size) { const struct snd_kcontrol_new *kc; struct soc_mixer_control *sm; struct soc_bytes_ext *sbe; struct soc_enum *se; - size_t size = 0; int i; + *size = 0; + for (i = 0; i < widget->num_kcontrols; i++) { kc = &widget->kcontrol_news[i]; @@ -1800,7 +1802,7 @@ static size_t sof_get_control_data(struct snd_sof_dev *sdev, if (wdata[i].pdata->magic != SOF_ABI_MAGIC) return -EINVAL; - size += wdata[i].pdata->size; + *size += wdata[i].pdata->size; /* get data type */ switch (wdata[i].control->cmd) { @@ -1819,7 +1821,7 @@ static size_t sof_get_control_data(struct snd_sof_dev *sdev, } } - return size; + return 0; } static int sof_process_load(struct snd_soc_component *scomp, int index, @@ -1855,12 +1857,11 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, return -ENOMEM; /* get possible component controls and get size of all pdata */ - ipc_data_size = sof_get_control_data(sdev, widget, wdata); + ret = sof_get_control_data(sdev, widget, wdata, + &ipc_data_size); - if (ipc_data_size <= 0) { - ret = ipc_data_size; + if (ret < 0) goto out; - } } ipc_size = sizeof(struct sof_ipc_comp_process) +