MLK-17220: ASoC: fsl_rpmsg_i2s: unlock mutex on error
authorViorel Suman <viorel.suman@nxp.com>
Tue, 12 Dec 2017 12:07:34 +0000 (14:07 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:51:33 +0000 (14:51 -0500)
Mutex must be unlocked when i2s_send_message method
fails.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
sound/soc/fsl/fsl_rpmsg_i2s.c

index 3cfa3e9..95cbe45 100644 (file)
@@ -35,7 +35,6 @@ static int i2s_send_message(struct i2s_rpmsg_s *msg,
 {
        int err;
 
-       mutex_lock(&info->tx_lock);
        if (!info->rpdev) {
                dev_dbg(info->dev, "rpmsg channel not ready, m4 image ready?\n");
                return -EINVAL;
@@ -43,11 +42,14 @@ static int i2s_send_message(struct i2s_rpmsg_s *msg,
 
        dev_dbg(&info->rpdev->dev, "send cmd %d\n", msg->header.cmd);
 
+       mutex_lock(&info->tx_lock);
+
        reinit_completion(&info->cmd_complete);
        err = rpmsg_send(info->rpdev->ept, (void *)msg,
                         sizeof(struct i2s_rpmsg_s));
        if (err) {
                dev_err(&info->rpdev->dev, "rpmsg_send failed: %d\n", err);
+               mutex_unlock(&info->tx_lock);
                return err;
        }
 
@@ -57,6 +59,7 @@ static int i2s_send_message(struct i2s_rpmsg_s *msg,
        if (!err) {
                dev_err(&info->rpdev->dev, "rpmsg_send cmd %d timeout!\n",
                                                        msg->header.cmd);
+               mutex_unlock(&info->tx_lock);
                return -ETIMEDOUT;
        }