pwm: fsl-ftm: Make sure to unlock mutex on failure
authorThierry Reding <thierry.reding@gmail.com>
Wed, 26 Jun 2019 09:36:40 +0000 (11:36 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 26 Jun 2019 09:39:25 +0000 (11:39 +0200)
Upon failure to enable clocks while trying to enable the PWM, make sure
to unlock the mutex that was taken to avoid a deadlock during subsequent
operations.

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Cc: Patrick Havelange <patrick.havelange@essensium.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-fsl-ftm.c

index 6a4106c65cb4b42964a33c213bc351e628872249..efc226bda2146c01aa550ab910597f360e9ce2e0 100644 (file)
@@ -342,12 +342,12 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
        if (!oldstate->enabled) {
                ret = clk_prepare_enable(fpc->clk[fpc->period.clk_select]);
                if (ret)
-                       return ret;
+                       goto end_mutex;
 
                ret = clk_prepare_enable(fpc->clk[FSL_PWM_CLK_CNTEN]);
                if (ret) {
                        clk_disable_unprepare(fpc->clk[fpc->period.clk_select]);
-                       return ret;
+                       goto end_mutex;
                }
 
                regmap_update_bits(fpc->regmap, FTM_OUTMASK, BIT(pwm->hwpwm),