Skip to content

Commit

Permalink
ASoC: soc-pcm: don't use bit-OR'ed error
Browse files Browse the repository at this point in the history
Current soc-pcm is using bit-OR'ed error

	ret |= snd_soc_component_close(component, substream);
	ret |= snd_soc_component_hw_free(component, substream);

The driver may return arbitrary error codes so they can conflict.
The bit-OR'ed error works only if the return code is always consistent.
This patch fixup it, and use *last* ret value.

Signed-off-by: Kuninori Morimoto <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
morimoto authored and broonie committed Feb 11, 2020
1 parent 09e88f8 commit e82ebff
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,16 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
int i, r, ret = 0;

for_each_rtd_components(rtd, i, component) {
if (component == last)
break;

ret |= snd_soc_component_close(component, substream);
r = snd_soc_component_close(component, substream);
if (r < 0)
ret = r; /* use last ret */

snd_soc_component_module_put_when_close(component);
}

Expand Down Expand Up @@ -798,13 +801,15 @@ static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream,
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component;
int i, ret = 0;
int i, r, ret = 0;

for_each_rtd_components(rtd, i, component) {
if (component == last)
break;

ret |= snd_soc_component_hw_free(component, substream);
r = snd_soc_component_hw_free(component, substream);
if (r < 0)
ret = r; /* use last ret */
}

return ret;
Expand Down

0 comments on commit e82ebff

Please sign in to comment.