From patchwork Fri Sep 25 01:37:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 7261941 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0EB669F30C for ; Fri, 25 Sep 2015 01:37:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 470C620A7A for ; Fri, 25 Sep 2015 01:37:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63B1E209E6 for ; Fri, 25 Sep 2015 01:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753391AbbIYBha (ORCPT ); Thu, 24 Sep 2015 21:37:30 -0400 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 From: Bjorn Andersson To: Andy Gross CC: Courtney Cavin , , , 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> X-Mailer: git-send-email 1.8.2.2 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Andy Gross --- 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;