From patchwork Mon Jul 10 01:19:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 701122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CFD49EB64DC for ; Mon, 10 Jul 2023 01:21:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 282437F4; Mon, 10 Jul 2023 03:20:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 282437F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1688952066; bh=/momY0dBUMy6QNsUAmpXUVtW8Ad9C4R4HfkwPq0Z44Q=; h=Date:From:Subject:To:Cc:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BN40YU+3RuiGFnY2LZFZ45jL5ulLTupQvbX7U32wnab9Kd1IJzb8R9NCduoAuIe8J 1xFLg1E9Dx/QWlCM1s0EBPBOcwCaDvBEecuxZRToQ09eCuRg5jzj0WoSuaoHNWZKO+ ynw+GxYb+OT/EVd+H/bVEkVkKHwym4EhTc8TOt9o= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3507F80557; Mon, 10 Jul 2023 03:19:43 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A1209F80548; Mon, 10 Jul 2023 03:19:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A2E89F80544; Mon, 10 Jul 2023 03:19:40 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 59976F80249 for ; Mon, 10 Jul 2023 03:19:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 59976F80249 Date: 10 Jul 2023 10:19:32 +0900 X-IronPort-AV: E=Sophos;i="6.01,193,1684767600"; d="scan'208";a="167840555" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 10 Jul 2023 10:19:32 +0900 Received: from venus.renesas.com (unknown [10.166.252.89]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id E91C8400B9F1; Mon, 10 Jul 2023 10:19:32 +0900 (JST) Message-ID: <87lefoo95n.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 01/15] ASoC: soc-core: protect dlc->of_node under mutex User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown , Cezary Rojewski , "Pierre-Louis Bossart" , =?iso-8859-2?q?=22Amadeusz_S=B3awi=F1ski=22?= Cc: Linux-ALSA In-Reply-To: <87mt04o96f.wl-kuninori.morimoto.gx@renesas.com> References: <87mt04o96f.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Message-ID-Hash: JZVW6NWDRDNUER72S4KDCXHKLE52CAPW X-Message-ID-Hash: JZVW6NWDRDNUER72S4KDCXHKLE52CAPW X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: dlc->of_node will be set on snd_soc_get_dlc(), but we want 1) protect it by mutex, 2) set only when successed. This patch do it. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1a0bde23f5e6..51791f8b2af3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3264,8 +3264,6 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_ struct snd_soc_component *pos; int ret = -EPROBE_DEFER; - dlc->of_node = args->np; - mutex_lock(&client_mutex); for_each_component(pos) { struct device_node *component_of_node = soc_component_to_node(pos); @@ -3319,6 +3317,10 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_ break; } + + if (ret == 0) + dlc->of_node = args->np; + mutex_unlock(&client_mutex); return ret; }