From patchwork Wed Oct 19 08:28:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5042 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp247178wrs; Wed, 19 Oct 2022 03:40:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5nMIztu1HNt0QOYpgt/ebkDr+n5fF1HbUdQ1bhQZvHyLbQHWCHLUszkW+V3ljQlnNpX0Nq X-Received: by 2002:a05:6402:350f:b0:45d:1d86:9ec9 with SMTP id b15-20020a056402350f00b0045d1d869ec9mr6894952edd.266.1666176010638; Wed, 19 Oct 2022 03:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176010; cv=none; d=google.com; s=arc-20160816; b=csMfxLk5FGmHwT9ibnP5GfVYG9kPaDErWjEqYf/FY5DNjZF9+orD1ZhBjlaX9M2bwF fowHJW+OJEQHswUuGuXeKoLvLrih/S7IFNV+CHbmnqA6QQ+no0w5muO5jm3k1OTGsWGZ Vn6vl/8BGgoFRcRAONk2fE4nDdsj/wEsmcZwR+4mhTVHxTsQugvF4ksDeeaWWs/ySPtQ zSRrN+wP9dNNtMUx/OG7xCRRspPIqTrYsRoNdofCLeLLdCtcPuS0lk75OaeEMlZGUHcw J5cji5ssjNu2KgJaFQK2pqsjBsJ2CrMKXalELcgEyxfV/DizA41VNr6nUcnQJ3bfS94T voyQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j30-20020a508a9e000000b0044dbb9afe1fsi12722738edj.467.2022.10.19.03.39.45; Wed, 19 Oct 2022 03:40:10 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112176452028109?= X-GMAIL-MSGID: =?utf-8?q?1747112176452028109?= 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; }