From 0e1bf571a6060210eef9bad13e5a564512efc8e7 Mon Sep 17 00:00:00 2001 From: Liviu Dudau Date: Thu, 24 Jul 2014 11:14:21 +0100 Subject: [PATCH] mailbox: scpi: Free the mailbox channel when we fail to queue a message. 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 Signed-off-by: Liviu Dudau --- drivers/mailbox/scpi_protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/scpi_protocol.c b/drivers/mailbox/scpi_protocol.c index 0a208bf..95d3368 100644 --- a/drivers/mailbox/scpi_protocol.c +++ b/drivers/mailbox/scpi_protocol.c @@ -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); -- 2.7.4