Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724611pxb; Tue, 2 Feb 2021 16:47:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHvDKlgBFdMvOjoOxTEX52pgvFmvhodXnDGahgOO6zGbrzY9atSYPRIjDPG8bOsBuKBUzt X-Received: by 2002:a17:906:e43:: with SMTP id q3mr560833eji.493.1612313229502; Tue, 02 Feb 2021 16:47:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313229; cv=none; d=google.com; s=arc-20160816; b=XNwn1jLahoVFC1oJewm00pHNs3DceacmjIMAs1wT37Lo7/RpgURW1xlj9zBzUCRHQO oR0kkoLcP9E/voM34H5sYYXJjbUsR37DigTHbxyH1nW9jlcVuQQray2KwWwr9nZIx+A2 kbxF/18Iwxe8awKQybfQe4Je6OHTCqq9L8IsVOho0ZCIHxAW6Tw1GQge6oInD21CoFXl qxZNoTumJZNanJY4IszkZVOhy1Cf3HS0BpKqNPilxh2IGPx6Nk2hsmiSsNvrl1AVJ1eu Y/X/qbK7mh6JYvIwQbWqkDV1gtoSpkhI4LAuSZcmc/W2x94S1xelSFsgti/da6J77Pnt LYdA== 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=vPGueWQHAjsPvrbS/PW4of/LWRQ8xq92qgkgLMGMNIc=; b=eztifblrk1xJtuMy2RtZag4/pkhVWNvLHVvIZ4OX8hwdKwH+1v4KOVI2kr6mOkFF9E SOHgnRMMWwC/pzeLnTYbghTQ3+mD93eGeaoPnglmbOEOq76510DHJASRqO38T8w7Q4HO f727KTqYdt89IOvtuTcYq1mqd4GrCTMpj6LN8qUmlOrMr37Cnv17MDWz0i2ZF1YLNe2v pV6JdzJnKTSXKwjswNtO3oet7+YKKzL3TyesDsc2NM86VwOEo0wmvk/6ZZhtwP5JfvDP aTfuY9z4vbTohzSKQu7i+9qe1V8JXyqDZX69/Wd23LKkDDOZzkE1DkAaRZqigv9FEt/W 4YNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K7rJycKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si305461edi.216.2021.02.02.16.46.45; Tue, 02 Feb 2021 16:47:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K7rJycKH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S239768AbhBBTfg (ORCPT + 99 others); Tue, 2 Feb 2021 14:35:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:42400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233302AbhBBN4g (ORCPT ); Tue, 2 Feb 2021 08:56:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6587B64FDE; Tue, 2 Feb 2021 13:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273522; bh=mdqmBXuueKeG0pdRe54jBkL0RRK1cjuIaM54TGX+Z5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7rJycKHtqMGAzT9Kkcr/kgSEnCPSDqc3MmzARdvShNu8klRoCZegxjyARJxjApoq 123/VgvwgLYG+OxR8AAhX/6rOR/Yj++cLmW9QzOlCSFyVB01QVE5tKkE4i4H1t7GSE ucMyhd/8FiRU3IH1c7keHGhwBwKrFpmPtg4jamLw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= , Pierre-Louis Bossart , Mark Brown Subject: [PATCH 5.10 137/142] ASoC: topology: Properly unregister DAI on removal Date: Tue, 2 Feb 2021 14:38:20 +0100 Message-Id: <20210202133003.341783247@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amadeusz Sławiński commit fc4cb1e15f0c66f2e37314349dc4a82bd946fbb1 upstream. DAIs need to be removed when topology unload function is called (usually done when component is being removed). We can't do this when device is being removed, as structures we operate on when removing DAI can already be freed. Fixes: 6ae4902f2f34 ("ASoC: soc-topology: use devm_snd_soc_register_dai()") Signed-off-by: Amadeusz Sławiński Tested-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20210120152846.1703655-2-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-topology.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -506,7 +506,7 @@ static void remove_dai(struct snd_soc_co { struct snd_soc_dai_driver *dai_drv = container_of(dobj, struct snd_soc_dai_driver, dobj); - struct snd_soc_dai *dai; + struct snd_soc_dai *dai, *_dai; if (pass != SOC_TPLG_PASS_PCM_DAI) return; @@ -514,9 +514,9 @@ static void remove_dai(struct snd_soc_co if (dobj->ops && dobj->ops->dai_unload) dobj->ops->dai_unload(comp, dobj); - for_each_component_dais(comp, dai) + for_each_component_dais_safe(comp, dai, _dai) if (dai->driver == dai_drv) - dai->driver = NULL; + snd_soc_unregister_dai(dai); kfree(dai_drv->playback.stream_name); kfree(dai_drv->capture.stream_name); @@ -1876,7 +1876,7 @@ static int soc_tplg_dai_create(struct so list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list); /* register the DAI to the component */ - dai = devm_snd_soc_register_dai(tplg->comp->dev, tplg->comp, dai_drv, false); + dai = snd_soc_register_dai(tplg->comp, dai_drv, false); if (!dai) return -ENOMEM; @@ -1884,6 +1884,7 @@ static int soc_tplg_dai_create(struct so ret = snd_soc_dapm_new_dai_widgets(dapm, dai); if (ret != 0) { dev_err(dai->dev, "Failed to create DAI widgets %d\n", ret); + snd_soc_unregister_dai(dai); return ret; }