Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp877184rwi; Wed, 19 Oct 2022 04:12:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MQmsWR2igX7d4QJiMW27ivDAWb2ZcLqx9YPt09qL42qMKPtHwcQoO+UTc5M357Ms1XUau X-Received: by 2002:a63:69c2:0:b0:46a:eeb1:e784 with SMTP id e185-20020a6369c2000000b0046aeeb1e784mr6716464pgc.589.1666177956908; Wed, 19 Oct 2022 04:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177956; cv=none; d=google.com; s=arc-20160816; b=W3eTqlsUQFSj5OGcF7HYO7cDkFXpabmN/vEV3J1/TiTMmPVmla+1mLPj8znKGhmZ73 kJGE48lM/2/BSUEH1Q1uRlu0znkWweUFzi1FPCRfVwDbySvgedFH1hs3fjoUs/O9tMpw MLt5+Su7t2J3biHnlChIDJ360J5PwINGTs6M/TDI5YECXtZRgSxVzvCOyZh/8fEpwBEB /iXlDeinsxmXKkSHrg5jjChuwlUTo7Y5PPpUtLoDv+TG8kcDb4MbMdLFrLJBBGEp39m9 9uo/ISX2hK0kICddXpxQSDSgsctmw7MOtqGqkfesk8ip01VBYRAV0g0fAJiWQbCFNZpf vJ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=alo9Z7aJSVpsPSGvybDZF2OpjX4E3VHyuzefJYokAJc=; b=gjgpoOUqdP7Z0Vzo2lOymyXVr9pq6a7lQCNN7L3xk7SM2NpMvN5vgFNuR71/hli8aC QtkGDlQsHlVFeRcXlzLBIuo+14iZFv0iCj6DIp1gjzub53pyRWrUKv6xXiniE7mE/Yc5 JJ6yPyJgp12hcIcmVdP2p2Br9oJUK+opE2YEZMy26DIpnUwh7R9fmCW0oXMh7IUmRCfR 2anW+MMS1m/G2TUNqtP5jyprtQ4iJEwltAVVcNmio9TI0gZDH804uCuJ3BmsvME7PGTK glzjviDdas5IeNhAHQnogaMYKRNSJiI+180birf7U6NFq5XI0GwGgIpYx+weH4FrTTA5 EeEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1vPAX6LP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb10-20020a17090b280a00b001fdd2a56d6dsi23449518pjb.43.2022.10.19.04.12.21; Wed, 19 Oct 2022 04:12:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1vPAX6LP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231931AbiJSKiP (ORCPT + 99 others); Wed, 19 Oct 2022 06:38:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231919AbiJSKhq (ORCPT ); Wed, 19 Oct 2022 06:37:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B752152C51; Wed, 19 Oct 2022 03:16:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 70799B82423; Wed, 19 Oct 2022 08:56:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA2FBC4314C; Wed, 19 Oct 2022 08:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169761; bh=F1JXg42jhGfBnXQLzlro4hM3EZNVZO8juWCR9Pai+GE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1vPAX6LPzq7ksEAq05MpmOKaCU426zAiYwfC+EhuY9crPnQlyZfCWzBqymG5KCcTw WlO3snSaD2C1TEFo2Siy9UiEouokQxqMpBtBPfuzmE91mzyKNlVJpBdG3UEb1krLvJ rZbCqFASfsS46fW4ef/qFtWEYu+vk667YNtjKJGI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Ujfalusi , Ranjani Sridharan , Bard Liao , Pierre-Louis Bossart , Mark Brown , Sasha Levin Subject: [PATCH 6.0 398/862] ASoC: SOF: ipc4-topology: Free the ida when IPC fails in sof_ipc4_widget_setup() Date: Wed, 19 Oct 2022 10:28:05 +0200 Message-Id: <20221019083307.525506018@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Ujfalusi [ Upstream commit 61eb0add28023119773d6aab8f402e149473920c ] The allocated ida needs to be freed up if the IPC message fails since next time when we try again to set up the widget we are going to try to allocate another ID and given enough tries, we are going to run out of unique IDs. Fixes: 711d0427c713 ("ASoC: SOF: ipc4-topology: move ida allocate/free to widget_setup/free") Signed-off-by: Peter Ujfalusi Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20220921112751.9253-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/ipc4-topology.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 64929dc9af39..340d92452d7c 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -1544,9 +1544,16 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget msg->data_ptr = ipc_data; ret = sof_ipc_tx_message(sdev->ipc, msg, ipc_size, NULL, 0); - if (ret < 0) + if (ret < 0) { dev_err(sdev->dev, "failed to create module %s\n", swidget->widget->name); + if (swidget->id != snd_soc_dapm_scheduler) { + struct sof_ipc4_fw_module *fw_module = swidget->module_info; + + ida_free(&fw_module->m_ida, swidget->instance_id); + } + } + return ret; } -- 2.35.1