From: Bjorn Andersson Subject: [PATCH] soc: qcom: smd: Reject send of too big packets Date: Thu, 24 Sep 2015 18:37:18 -0700 Message-ID: <1443145038-30699-1-git-send-email-bjorn.andersson@sonymobile.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from jptorel01.sonyericsson.com ([124.215.201.70]:1367 "EHLO jptorel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752954AbbIYBh3 (ORCPT ); Thu, 24 Sep 2015 21:37:29 -0400 Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Andy Gross Cc: Courtney Cavin , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Attempting to find room for a packet that's bigger than the fifo will never succeed and the calling process will be sleeping forever in the loop, waiting for enough room. So fail early instead. Reported-by: Courtney Cavin Signed-off-by: Bjorn Andersson --- drivers/soc/qcom/smd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/soc/qcom/smd.c b/drivers/soc/qcom/smd.c index 18964f154383..88353bda1ea4 100644 --- a/drivers/soc/qcom/smd.c +++ b/drivers/soc/qcom/smd.c @@ -723,6 +723,10 @@ int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len) if (channel->info_word && len % 4) return -EINVAL; + /* Reject packets that are too big */ + if (tlen >= channel->fifo_size) + return -EINVAL; + ret = mutex_lock_interruptible(&channel->tx_lock); if (ret) return ret; -- 1.8.2.2