From patchwork Mon Sep 21 16:27:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 263685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8410BC43468 for ; Mon, 21 Sep 2020 16:44:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 481E723976 for ; Mon, 21 Sep 2020 16:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706687; bh=QkzFQtbOcFPW+YmrwgpR1H5unI/XIA0Ur6NRyF5Tddo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Pdiixlw11bSaLLTbt6tfpEdQMvFWA53SOAllMW03QEIlbEh7G0Mx1DjwNmBr9eDtp qfdBWOl1rbQVBVlgGmrx63lkolue5fq8/Y88r85SAeHyjRr+uYIb/88EANSmvuYQqm 8oIhybOaydpel30z7Xb81S/h3yZn30V1x7QIsHNg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729707AbgIUQoo (ORCPT ); Mon, 21 Sep 2020 12:44:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:50204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729702AbgIUQon (ORCPT ); Mon, 21 Sep 2020 12:44:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC8DF2076B; Mon, 21 Sep 2020 16:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706682; bh=QkzFQtbOcFPW+YmrwgpR1H5unI/XIA0Ur6NRyF5Tddo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/nHvgxE+JSF96kDAZ7QergbT3FkdprpdnexYBNtStEXaCTxh6DeC5q9SqblXVNPi 3N1Wv0GD2aCvvb4sSDUfyixx1J8+5ZMx7iuCB+EHi38sbnyGcsl7MAKrCguMwY02/r gKhJqONMCVeHpac1JvA6SC2ZYn9FA7vb6YQaS3Us= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cezary Rojewski , Liam Girdwood , Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.8 051/118] ASoC: core: Do not cleanup uninitialized dais on soc_pcm_open failure Date: Mon, 21 Sep 2020 18:27:43 +0200 Message-Id: <20200921162038.697814598@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Cezary Rojewski [ Upstream commit 20244b2a8a8728c63233d33146e007dcacbcc5c4 ] Introduce for_each_rtd_dais_rollback macro which behaves exactly like for_each_codec_dais_rollback and its cpu_dais equivalent but for all dais instead. Use newly added macro to fix soc_pcm_open error path and prevent uninitialized dais from being cleaned-up. Signed-off-by: Cezary Rojewski Fixes: 5d9fa03e6c35 ("ASoC: soc-pcm: tidyup soc_pcm_open() order") Acked-by: Liam Girdwood Acked-by: Kuninori Morimoto Link: https://lore.kernel.org/r/20200907111939.16169-1-cezary.rojewski@intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- include/sound/soc.h | 2 ++ sound/soc/soc-pcm.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index bc6ecb10c7649..ca765062787b0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1205,6 +1205,8 @@ struct snd_soc_pcm_runtime { ((i) < (rtd)->num_cpus + (rtd)->num_codecs) && \ ((dai) = (rtd)->dais[i]); \ (i)++) +#define for_each_rtd_dais_rollback(rtd, i, dai) \ + for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);) void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 74baf1fce053f..918ed77726cc0 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -811,7 +811,7 @@ dynamic: return 0; config_err: - for_each_rtd_dais(rtd, i, dai) + for_each_rtd_dais_rollback(rtd, i, dai) snd_soc_dai_shutdown(dai, substream); snd_soc_link_shutdown(substream);