mailbox: scpi: Free the mailbox channel when we fail to queue a message.
authorLiviu Dudau <Liviu.Dudau@arm.com>
Thu, 24 Jul 2014 10:14:21 +0000 (11:14 +0100)
committerLiviu Dudau <Liviu.Dudau@arm.com>
Thu, 24 Jul 2014 11:24:31 +0000 (12:24 +0100)
When sending an SCPI command we aquire a channel and queue the
message in the mailbox. If the queuing failed we were not releasing
the channel hence preventing everyone else from using it.

Signed-off-by: Punit Agrawal <Punit.Agrawal@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
drivers/mailbox/scpi_protocol.c

index 0a208bf..95d3368 100644 (file)
@@ -180,8 +180,10 @@ static int send_scpi_cmd(struct scpi_data_buf *scpi_buf, bool high_priority)
                return PTR_ERR(chan);
 
        init_completion(&scpi_buf->complete);
-       if (mbox_send_message(chan, (void *)data))
-               return -EIO;
+       if (mbox_send_message(chan, (void *)data) < 0) {
+               status = SCPI_ERR_TIMEOUT;
+               goto free_channel;
+       }
 
        if (!wait_for_completion_timeout(&scpi_buf->complete,
                                         msecs_to_jiffies(50)))
@@ -189,6 +191,7 @@ static int send_scpi_cmd(struct scpi_data_buf *scpi_buf, bool high_priority)
        else
                status = *(u32 *)(data->rx_buf); /* read first word */
 
+free_channel:
        mbox_free_channel(chan);
 
        return scpi_to_linux_errno(status);