All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 6/8] ASoC: soc-pcm: fixup dpcm_be_dai_startup() user count
Date: 02 Mar 2021 10:48:18 +0900	[thread overview]
Message-ID: <87lfb6qqal.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87tupuqqc8.wl-kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

At dpcm_be_dai_startup_unwind(), it indicates error message at (1)
if this function was called with no users.
But, it doesn't use "continue" here. Thus, it will be minus
users at (2).

	void dpcm_be_dai_startup_unwind(...)
	{
		...
		for_each_dpcm_be(...) {
			...
(1)			if (be->dpcm[stream].users == 0)
				dev_err(...);

(2)			if (--be->dpcm[stream].users != 0)
				continue;

At dpcm_be_dai_startup(), it indicates error message if
user reached to MAX USERS at (A).
But, it doesn't use "continue" here. Thus, it will be over
MAX USERS at (B).

	int dpcm_be_dai_startup(...)
	{
		...
		for_each_dpcm_be(...) {
			...
(A)			if (be->dpcm[stream].users == DPCM_MAX_BE_USERS)
				dev_err(...);

(B)			if (be->dpcm[stream].users++ != 0)
				continue;

These are just bug. This patch fixup these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index aa1f26ccb0dc..925f687652c6 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1428,10 +1428,12 @@ static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe,
 		struct snd_pcm_substream *be_substream =
 			snd_soc_dpcm_get_substream(be, stream);
 
-		if (be->dpcm[stream].users == 0)
+		if (be->dpcm[stream].users == 0) {
 			dev_err(be->dev, "ASoC: no users %s at close - state %d\n",
 				stream ? "capture" : "playback",
 				be->dpcm[stream].state);
+			continue;
+		}
 
 		if (--be->dpcm[stream].users != 0)
 			continue;
@@ -1468,10 +1470,12 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
 			continue;
 
 		/* first time the dpcm is open ? */
-		if (be->dpcm[stream].users == DPCM_MAX_BE_USERS)
+		if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) {
 			dev_err(be->dev, "ASoC: too many users %s at open %d\n",
 				stream ? "capture" : "playback",
 				be->dpcm[stream].state);
+			continue;
+		}
 
 		if (be->dpcm[stream].users++ != 0)
 			continue;
@@ -1513,10 +1517,12 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
 		if (!snd_soc_dpcm_be_can_update(fe, be, stream))
 			continue;
 
-		if (be->dpcm[stream].users == 0)
+		if (be->dpcm[stream].users == 0) {
 			dev_err(be->dev, "ASoC: no users %s at close %d\n",
 				stream ? "capture" : "playback",
 				be->dpcm[stream].state);
+			continue;
+		}
 
 		if (--be->dpcm[stream].users != 0)
 			continue;
-- 
2.25.1


  parent reply	other threads:[~2021-03-02  1:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02  1:47 [PATCH 0/8] ASoC: soc-pcm: cleanup each functions Kuninori Morimoto
2021-03-02  1:47 ` [PATCH 1/8] ASoC: soc-pcm: check DAI activity under soc_pcm_apply_symmetry() Kuninori Morimoto
2021-03-02  1:47 ` [PATCH 2/8] ASoC: soc-pcm: add soc_cpu/codec_dai_name() macro Kuninori Morimoto
2021-03-02 13:04   ` Mark Brown
2021-03-04 22:04     ` Kuninori Morimoto
2021-03-02  1:48 ` [PATCH 3/8] ASoC: soc-pcm: direct copy at snd_soc_set_runtime_hwparams() Kuninori Morimoto
2021-03-02  1:48 ` [PATCH 4/8] ASoC: soc-pcm: add soc_pcm_care_symmetry() Kuninori Morimoto
2021-03-02 13:10   ` Mark Brown
2021-03-04 22:06     ` Kuninori Morimoto
2021-03-02  1:48 ` [PATCH 5/8] ASoC: soc-pcm: add soc_hw_sanity_check() Kuninori Morimoto
2021-03-02  1:48 ` Kuninori Morimoto [this message]
2021-03-02  1:48 ` [PATCH 7/8] ASoC: soc-pcm: remove unneeded !rtd->dai_link check Kuninori Morimoto
2021-03-02  1:48 ` [PATCH 8/8] ASoC: soc-pcm: share DPCM BE DAI stop operation Kuninori Morimoto
2021-03-05  0:59 [PATCH v2 0/8] ASoC: soc-pcm: cleanup each functions Kuninori Morimoto
2021-03-05  1:00 ` [PATCH 6/8] ASoC: soc-pcm: fixup dpcm_be_dai_startup() user count Kuninori Morimoto
2021-03-05 16:14   ` Pierre-Louis Bossart
2021-03-07 22:37     ` Kuninori Morimoto
2021-03-08 13:32       ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lfb6qqal.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.