public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()
@ 2018-12-21  9:11 Dan Carpenter
  2018-12-21 11:23 ` Dimitris Papavasiliou
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dan Carpenter @ 2018-12-21  9:11 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: alsa-devel, Kuninori Morimoto, kernel-janitors, Takashi Iwai,
	Dimitris Papavasiliou, Mark Brown

We accidentally call mutex_unlock(&pcm512x->mutex); twice in a row.

I re-wrote the error handling to use "goto unlock;" instead of returning
directly.  Hopefully, it makes the code a little simpler.

Fixes: 3500f1c589e9 ("ASoC: pcm512x: Implement the digital_mute interface")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/codecs/pcm512x.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 6cb1653be804..4cc24a5d5c31 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1400,24 +1400,20 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
 		if (ret != 0) {
 			dev_err(component->dev,
 				"Failed to set digital mute: %d\n", ret);
-			mutex_unlock(&pcm512x->mutex);
-			return ret;
+			goto unlock;
 		}
 
 		regmap_read_poll_timeout(pcm512x->regmap,
 					 PCM512x_ANALOG_MUTE_DET,
 					 mute_det, (mute_det & 0x3) = 0,
 					 200, 10000);
-
-		mutex_unlock(&pcm512x->mutex);
 	} else {
 		pcm512x->mute &= ~0x1;
 		ret = pcm512x_update_mute(pcm512x);
 		if (ret != 0) {
 			dev_err(component->dev,
 				"Failed to update digital mute: %d\n", ret);
-			mutex_unlock(&pcm512x->mutex);
-			return ret;
+			goto unlock;
 		}
 
 		regmap_read_poll_timeout(pcm512x->regmap,
@@ -1428,9 +1424,10 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
 					 200, 10000);
 	}
 
+unlock:
 	mutex_unlock(&pcm512x->mutex);
 
-	return 0;
+	return ret;
 }
 
 static const struct snd_soc_dai_ops pcm512x_dai_ops = {
-- 
2.17.1

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

end of thread, other threads:[~2018-12-21 13:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-21  9:11 [PATCH] ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute() Dan Carpenter
2018-12-21 11:23 ` Dimitris Papavasiliou
2018-12-21 12:00   ` Dan Carpenter
2018-12-21 12:10     ` Mark Brown
2018-12-21 13:54       ` Dimitris Papavasiliou
2018-12-21 13:42 ` Applied "ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()" to the asoc tree Mark Brown
2018-12-21 13:51 ` [PATCH] ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute() Dimitris Papavasiliou

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