Skip to contentSkip to conversation

ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()

PATCH In review Dan Carpenter 3 participants 7 messages Dec 21, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()

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")
---
 sound/soc/codecs/pcm512x.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/codecs/pcm512x.c +4 -7
index 6cb1653be804..4cc24a5d5c31 100644
@@ -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 = {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 1 line · Dan Carpenter

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

Ooops... Looks like I left a spare unlock in there. Thanks for catching and fixing it!

Maintainers, please let me know if there's anything I need to do with respect to this.

author Reviewed-by Your Name
#2 lore raw
Quoted 5 lines · Dimitris Papavasiliou
Quoted 1 line · Dan Carpenter

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

Ooops... Looks like I left a spare unlock in there. Thanks for catching and fixing it!

Static analysis stuff... No big deal.

Quoted 3 lines

Maintainers, please let me know if there's anything I need to do with respect to this.

All you need to is reply with a reviewed-by tag so we can mark on the fix that you approved it.

Reviewed-by Your Name <email>

regards,
dan carpenter

maintainer
#3 lore raw
Quoted 9 lines · Dan Carpenter
Quoted 2 lines · Dimitris Papavasiliou

Maintainers, please let me know if there's anything I need to do with respect to this.

All you need to is reply with a reviewed-by tag so we can mark on the fix that you approved it.

Reviewed-by Your Name <email>

I've just gone and applied the tag but yeah, what Dan says - there's tools that can pick tags like this out of e-mail which is also useful.

#4 lore raw
Quoted 6 lines · Mark Brown
Quoted 4 lines · Dan Carpenter
Quoted 2 lines · Dimitris Papavasiliou

Maintainers, please let me know if there's anything I need to do with respect to this.

Quoted 7 lines
Quoted 4 lines

All you need to is reply with a reviewed-by tag so we can mark on the fix that you approved it.

Reviewed-by Your Name <email>

I've just gone and applied the tag but yeah, what Dan says - there's tools that can pick tags like this out of e-mail which is also useful.

Thanks to both, but Mark, I'm afraid you've misspelled "Reviewed" in the patch you applied.

maintainer
#5 lore raw

Applied "ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()" to the asoc tree

In reply to Dan Carpenter

The patch

ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()

has been applied to the asoc tree at

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

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

From 35c299625b68369518bf45f99b8052ec2394d10e Mon Sep 17 00:00:00 2001
From: Dan Carpenter <[email protected]>
Date: Fri, 21 Dec 2018 12:11:20 +0300
Subject: [PATCH] ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute()

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")
---
 sound/soc/codecs/pcm512x.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/codecs/pcm512x.c +4 -7
index 6cb1653be804..4cc24a5d5c31 100644
@@ -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 = {
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#6 lore raw
In reply to Dan Carpenter
Quoted 10 lines · Dan Carpenter

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")
---
  sound/soc/codecs/pcm512x.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)