83113e92cdd53e41bdac45eb702a628d8dde8d0e
[oweals/openwrt.git] /
1 From e0d60424f966b62d61300cec4ba7fd070abaf772 Mon Sep 17 00:00:00 2001
2 From: Dan Carpenter <dan.carpenter@oracle.com>
3 Date: Fri, 21 Dec 2018 12:11:20 +0300
4 Subject: [PATCH 341/703] ASoC: pcm512x: Fix a double unlock in
5  pcm512x_digital_mute()
6
7 [ Upstream commit 28b698b7342c7d5300cfe217cd77ff7d2a55e03d ]
8
9 We accidentally call mutex_unlock(&pcm512x->mutex); twice in a row.
10
11 I re-wrote the error handling to use "goto unlock;" instead of returning
12 directly.  Hopefully, it makes the code a little simpler.
13
14 Fixes: 3500f1c589e9 ("ASoC: pcm512x: Implement the digital_mute interface")
15 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
16 Reviwed-by: Dimitris Papavasiliou <dpapavas@gmail.com>
17 Signed-off-by: Mark Brown <broonie@kernel.org>
18 ---
19  sound/soc/codecs/pcm512x.c | 11 ++++-------
20  1 file changed, 4 insertions(+), 7 deletions(-)
21
22 --- a/sound/soc/codecs/pcm512x.c
23 +++ b/sound/soc/codecs/pcm512x.c
24 @@ -1404,24 +1404,20 @@ static int pcm512x_digital_mute(struct s
25                 if (ret != 0) {
26                         dev_err(component->dev,
27                                 "Failed to set digital mute: %d\n", ret);
28 -                       mutex_unlock(&pcm512x->mutex);
29 -                       return ret;
30 +                       goto unlock;
31                 }
32  
33                 regmap_read_poll_timeout(pcm512x->regmap,
34                                          PCM512x_ANALOG_MUTE_DET,
35                                          mute_det, (mute_det & 0x3) == 0,
36                                          200, 10000);
37 -
38 -               mutex_unlock(&pcm512x->mutex);
39         } else {
40                 pcm512x->mute &= ~0x1;
41                 ret = pcm512x_update_mute(pcm512x);
42                 if (ret != 0) {
43                         dev_err(component->dev,
44                                 "Failed to update digital mute: %d\n", ret);
45 -                       mutex_unlock(&pcm512x->mutex);
46 -                       return ret;
47 +                       goto unlock;
48                 }
49  
50                 regmap_read_poll_timeout(pcm512x->regmap,
51 @@ -1432,9 +1428,10 @@ static int pcm512x_digital_mute(struct s
52                                          200, 10000);
53         }
54  
55 +unlock:
56         mutex_unlock(&pcm512x->mutex);
57  
58 -       return 0;
59 +       return ret;
60  }
61  
62  static int pcm512x_set_tdm_slot(struct snd_soc_dai *dai,