Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp443721iog; Mon, 13 Jun 2022 06:06:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwpp0D+KUeziwOYW6CQDPxcdwYJYiv93qlzh7Hc3xZo3J9klMXfomwpbq63OjgdQSrED9J X-Received: by 2002:a05:6402:5114:b0:42f:b5f3:1f96 with SMTP id m20-20020a056402511400b0042fb5f31f96mr54026801edd.260.1655125619032; Mon, 13 Jun 2022 06:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125619; cv=none; d=google.com; s=arc-20160816; b=yRALmhEOuTXJtEFuQdA0CmwBH3KT1SWNVNN4wypf1DFwhLqXtN0KjSjYVmbLQtdTb4 zLotLeq7jw/VZqiXotM833eH6oqY97fnrDGLK4T6p8FofMEwdi0L/IPMZEx69oCaNmRU LF0AbiXL/G6VSjKClvdVijjyRkSzyE4IWkmXsXQcVXZws/ruwY0gRyctfMzK/h8F45aK Zfd/BiLbdOVlVKy8Zw8TnQF1IqBi9Codh0yVnNBtAcYMQ9KMRZBFpi9aM1+20q78WZL2 RNf8mFQmfrGF/OSjxIGRPe7QHP5XkpwN1XQBsHcC+4BbXSVi15cwlDe/eYnbbU7L+cJ/ AvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MyPeB9gQSFUIOOhBy4Nzadq/s30TJdwM/Wj+X4ZZPuA=; b=m8YWA/eK+2AgM7fw48Fdv2pip8B2dXPnVcb8N1cSdcHRa9GSGGnEEWnc9UNRoGyqUS uOOA9G52S9TK7rE3NSmc9ClhhqFw4ngY0w0LehUui+mAL1a5p1Rk6IDvsBAvEKxhE/gv wrrVZobuElxbiiWBYO+UycXwV/hHTdO5jKTciPXh7l1ND75Hroe1V8boCjqtNCsOTlBP 0xf5rf9Te+AwkEZcMK4k1aCNCxbtVnR04qjrpuzGZwtbMRDws7+cpZomMEnap+67cxfn B8Wr5gKFqEKXQxB0X/SfYfExHUhsfwUxJyd9IqomJnXA6Ad2sAB3XCw504F/uNcw5hUH swFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zo1Wfuab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g30-20020a056402321e00b0042b38b9202dsi7879539eda.568.2022.06.13.06.06.16; Mon, 13 Jun 2022 06:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zo1Wfuab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236146AbiFMKTZ (ORCPT + 99 others); Mon, 13 Jun 2022 06:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241532AbiFMKSQ (ORCPT ); Mon, 13 Jun 2022 06:18:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F19DDEE6; Mon, 13 Jun 2022 03:16:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C4DB66144E; Mon, 13 Jun 2022 10:16:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4000C36B00; Mon, 13 Jun 2022 10:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115363; bh=o5D8cWAzSpLX6Ke+wFetopA+FTG86p/iMfzrOLTRMdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zo1Wfuabo+HIpEjdd73GvgHzu9Y80Hj1ZlP7pDx81W64hGxZYgJk4Mjm5X2CqOgbW GFvRORcsl/eP8gQvcAv9ESgnjTEZsgsQt09huBhwdBaIrh1r/hL7xt0QXLQF764AN5 y61DO499AIcuELoggTKMY4q7vP/cuOjoatFoscak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Dmitry Baryshkov , Abhinav Kumar , Marijn Suijten , Sasha Levin Subject: [PATCH 4.9 047/167] drm/msm/dsi: fix error checks and return values for DSI xmit functions Date: Mon, 13 Jun 2022 12:08:41 +0200 Message-Id: <20220613094851.997240070@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Baryshkov [ Upstream commit f0e7e9ed379c012c4d6b09a09b868accc426223c ] As noticed by Dan ([1] an the followup thread) there are multiple issues with the return values for MSM DSI command transmission callback. In the error case it can easily return a positive value when it should have returned a proper error code. This commits attempts to fix these issues both in TX and in RX paths. [1]: https://lore.kernel.org/linux-arm-msm/20211001123617.GH2283@kili/ Fixes: a689554ba6ed ("drm/msm: Initial add DSI connector support") Reported-by: Dan Carpenter Signed-off-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar Tested-by: Marijn Suijten Patchwork: https://patchwork.freedesktop.org/patch/480501/ Link: https://lore.kernel.org/r/20220401231104.967193-1-dmitry.baryshkov@linaro.org Signed-off-by: Dmitry Baryshkov Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/dsi/dsi_host.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 246336a9f47d..bea4969900ab 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1240,10 +1240,10 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, dsi_get_bpp(msm_host->format) / 8; len = dsi_cmd_dma_add(msm_host, msg); - if (!len) { + if (len < 0) { pr_err("%s: failed to add cmd type = 0x%x\n", __func__, msg->type); - return -EINVAL; + return len; } /* for video mode, do not send cmds more than @@ -1262,10 +1262,14 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host, } ret = dsi_cmd_dma_tx(msm_host, len); - if (ret < len) { - pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, len=%d\n", - __func__, msg->type, (*(u8 *)(msg->tx_buf)), len); - return -ECOMM; + if (ret < 0) { + pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, len=%d, ret=%d\n", + __func__, msg->type, (*(u8 *)(msg->tx_buf)), len, ret); + return ret; + } else if (ret < len) { + pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, ret=%d len=%d\n", + __func__, msg->type, (*(u8 *)(msg->tx_buf)), ret, len); + return -EIO; } return len; @@ -1979,9 +1983,12 @@ int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host, } ret = dsi_cmds2buf_tx(msm_host, msg); - if (ret < msg->tx_len) { + if (ret < 0) { pr_err("%s: Read cmd Tx failed, %d\n", __func__, ret); return ret; + } else if (ret < msg->tx_len) { + pr_err("%s: Read cmd Tx failed, too short: %d\n", __func__, ret); + return -ECOMM; } /* -- 2.35.1