diff mbox series

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

Message ID 20181221091120.GG2735@kadam (mailing list archive)
State Accepted
Commit 28b698b7342c7d5300cfe217cd77ff7d2a55e03d
Headers show
Series ASoC: pcm512x: Fix a double unlock in pcm512x_digital_mute() | expand

Commit Message

Dan Carpenter Dec. 21, 2018, 9:11 a.m. UTC
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(-)

Comments

Dimitris Papavasiliou Dec. 21, 2018, 11:23 a.m. UTC | #1
On 12/21/18 11:11 AM, Dan Carpenter wrote:
> 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.
Dan Carpenter Dec. 21, 2018, noon UTC | #2
On Fri, Dec 21, 2018 at 01:23:37PM +0200, Dimitris Papavasiliou wrote:
> On 12/21/18 11:11 AM, Dan Carpenter wrote:
> > 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.

> 
> 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
Mark Brown Dec. 21, 2018, 12:10 p.m. UTC | #3
On Fri, Dec 21, 2018 at 03:00:56PM +0300, Dan Carpenter wrote:
> On Fri, Dec 21, 2018 at 01:23:37PM +0200, Dimitris Papavasiliou wrote:

> > 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.
Dimitris Papavasiliou Dec. 21, 2018, 1:51 p.m. UTC | #4
On 12/21/18 11:11 AM, Dan Carpenter wrote:
> 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(-)

Reviewed-by: Dimitris Papavasiliou <dpapavas@gmail.com>
Dimitris Papavasiliou Dec. 21, 2018, 1:54 p.m. UTC | #5
On 12/21/18 2:10 PM, Mark Brown wrote:
> On Fri, Dec 21, 2018 at 03:00:56PM +0300, Dan Carpenter wrote:
>> On Fri, Dec 21, 2018 at 01:23:37PM +0200, Dimitris Papavasiliou wrote:
> 
>>> 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.

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

Patch

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 = {