public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger()
@ 2023-05-19  6:44 Harshit Mogalapalli
  2023-05-22 20:28 ` Ranjani Sridharan
  2023-05-23 19:50 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Harshit Mogalapalli @ 2023-05-19  6:44 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Peter Ujfalusi, Bard Liao,
	Ranjani Sridharan, Kai Vehmanen, Daniel Baluta, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Rander Wang, Jyri Sarha,
	sound-open-firmware, alsa-devel, linux-kernel
  Cc: harshit.m.mogalapalli, error27, dan.carpenter, kernel-janitors

hda_ipc4_pre_trigger() has two issues:
 1. In the default case, we are returning without unlocking the mutex.
 2. In case SNDRV_PCM_TRIGGER_STOP: when ret is less than zero it goes
    to out, unlocks but returns zero instead of a negative value.

Fix this by changing the final return value to 'ret' instead of zero,
and initialize 'ret' to zero in the start of the function.

Fixes: 225f37b578a9 ("ASoC: SOF: ipc4-pcm: reset all pipelines during FE DAI hw_free")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
Only compile tested. This is found using static anlysis with Smatch.
---
 sound/soc/sof/intel/hda-dai-ops.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c
index 5a508e118e3d..1e58256c8003 100644
--- a/sound/soc/sof/intel/hda-dai-ops.c
+++ b/sound/soc/sof/intel/hda-dai-ops.c
@@ -183,7 +183,7 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp
 	struct sof_ipc4_pipeline *pipeline;
 	struct snd_sof_widget *swidget;
 	struct snd_soc_dapm_widget *w;
-	int ret;
+	int ret = 0;
 
 	w = snd_soc_dai_get_widget(cpu_dai, substream->stream);
 	swidget = w->dobj.private;
@@ -208,11 +208,11 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp
 		break;
 	default:
 		dev_err(sdev->dev, "unknown trigger command %d\n", cmd);
-		return -EINVAL;
+		ret = -EINVAL;
 	}
 out:
 	mutex_unlock(&ipc4_data->pipeline_state_mutex);
-	return 0;
+	return ret;
 }
 
 static int hda_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH next] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger()
  2023-05-19  6:44 [PATCH next] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger() Harshit Mogalapalli
@ 2023-05-22 20:28 ` Ranjani Sridharan
  2023-05-23 19:50 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Ranjani Sridharan @ 2023-05-22 20:28 UTC (permalink / raw)
  To: Harshit Mogalapalli, Pierre-Louis Bossart, Liam Girdwood,
	Peter Ujfalusi, Bard Liao, Kai Vehmanen, Daniel Baluta,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Rander Wang,
	Jyri Sarha, sound-open-firmware, alsa-devel, linux-kernel
  Cc: error27, dan.carpenter, kernel-janitors

On Thu, 2023-05-18 at 23:44 -0700, Harshit Mogalapalli wrote:
> hda_ipc4_pre_trigger() has two issues:
>  1. In the default case, we are returning without unlocking the
> mutex.
>  2. In case SNDRV_PCM_TRIGGER_STOP: when ret is less than zero it
> goes
>     to out, unlocks but returns zero instead of a negative value.
> 
> Fix this by changing the final return value to 'ret' instead of zero,
> and initialize 'ret' to zero in the start of the function.
> 
> Fixes: 225f37b578a9 ("ASoC: SOF: ipc4-pcm: reset all pipelines during
> FE DAI hw_free")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> Only compile tested. This is found using static anlysis with Smatch.
> ---
Thanks for this fix. LGTM.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger()
  2023-05-19  6:44 [PATCH next] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger() Harshit Mogalapalli
  2023-05-22 20:28 ` Ranjani Sridharan
@ 2023-05-23 19:50 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2023-05-23 19:50 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Peter Ujfalusi, Bard Liao,
	Ranjani Sridharan, Kai Vehmanen, Daniel Baluta, Jaroslav Kysela,
	Takashi Iwai, Rander Wang, Jyri Sarha, sound-open-firmware,
	alsa-devel, linux-kernel, Harshit Mogalapalli
  Cc: error27, dan.carpenter, kernel-janitors

On Thu, 18 May 2023 23:44:01 -0700, Harshit Mogalapalli wrote:
> hda_ipc4_pre_trigger() has two issues:
>  1. In the default case, we are returning without unlocking the mutex.
>  2. In case SNDRV_PCM_TRIGGER_STOP: when ret is less than zero it goes
>     to out, unlocks but returns zero instead of a negative value.
> 
> Fix this by changing the final return value to 'ret' instead of zero,
> and initialize 'ret' to zero in the start of the function.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger()
      commit: ed67a3404a8806a57c0015ce97bd3e6d61e7aa22

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-23 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19  6:44 [PATCH next] ASoC: SOF: Intel: hda-dai: Fix locking in hda_ipc4_pre_trigger() Harshit Mogalapalli
2023-05-22 20:28 ` Ranjani Sridharan
2023-05-23 19:50 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox