Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2281319iof; Wed, 8 Jun 2022 01:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmfz44DgpEuRJb1KxOWXLHebBDP4ML7tvPOVHH8g7GZ2HrH+hiNva89wkKa1Fu47rPYopM X-Received: by 2002:a17:902:7449:b0:167:9520:d063 with SMTP id e9-20020a170902744900b001679520d063mr6977687plt.146.1654676330743; Wed, 08 Jun 2022 01:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676330; cv=none; d=google.com; s=arc-20160816; b=YU+sw2flWGvjOJOSlxYn4RX1h5UpH/FKT9LxxaaHCDpUymr3vKrX4iU3eHKswETkOk 0pi9aBVPnFYy4q1lC93qVj9h3owgXV7o8n/3/NaN4KcKwRGR78UNjfpkVxlu2onAAc28 6g6U8O5QVSFdXT6NmlxG5+K2qigbRPwDQRtuGi67oowKTdbTmcxcOK194SqioyF+muE5 y4YEeeeG1wqzROzfAZqQuYw05OXFNV8jmsPuF51LJOg/5O+/qAlLjQD8ZMJrCmXtBWcd 7NEwIgt/aY/6yQNQDqPkdKWycido8vPGoJNhEC9XFQ3mJwLdo4qaH3KhMLgash4MH6Sb J/Bg== 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=tc5ZPJMOZOseJR3ixYdBQxKJviZ4lz+bQl8Rhd6IA0Q=; b=eu+74wFVG2bLCrhVtIXFlG/CzD9nAtdV8jtvV6WE9j0D7EsM4FSIlpGTA0FyeTQHG6 7q4wGktMLVAtAdIF0oBrlvo+kQDlG39HdR1XRV7GmPzcy92qYl2JMyY61vSbGQHYbA9D PH+C1SQm0amC9OoctPqbJgy4hPxODhK9QVJQ6s2zRlQNZjI7K7kUKR6VDmZeze+fLu+v Y3X90d35gRMLxpomAG+XGLbz2xuwAQuVL3/FPF4JQ+CGZaxQd9rmPKACThWEI1TJKC09 rE1EH27GT9X6Q4PN38t2/L/ZKtRLIZgkpId8Qqe6ctu5OOaOEqrGvrHoyE2wucXlR67c Y/OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ask0KMTa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u11-20020a170902b28b00b00163fe7e3925si15845022plr.290.2022.06.08.01.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:18:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ask0KMTa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C97E22EA22; Wed, 8 Jun 2022 00:48:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385604AbiFGWqJ (ORCPT + 99 others); Tue, 7 Jun 2022 18:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380121AbiFGVe2 (ORCPT ); Tue, 7 Jun 2022 17:34:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC5D22D678; Tue, 7 Jun 2022 12:04:34 -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 7E261617F7; Tue, 7 Jun 2022 19:04:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 899D2C385A5; Tue, 7 Jun 2022 19:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628672; bh=TGwKHFfORsykFRv37mO2/R7Xx/hbUTP8zRLFkMjXmDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ask0KMTaxokDZNCBNReezsrrnAf0BcOjpihys/GhVTNMUuk0doHcwvhEDypuGT+tJ dbpfBc65FkZ5H5NcKeIfZoW27t+OAQhKHxzjBKeOYoDp4PA6eyoWAV/Cgeq9MBwNQK uVu1CkH8hQTZAzCSslv6Is0Th/nE++GRQHpgWEQQ= 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 5.18 373/879] drm/msm/dsi: fix error checks and return values for DSI xmit functions Date: Tue, 7 Jun 2022 18:58:11 +0200 Message-Id: <20220607165013.698712196@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 d51e70fab93d..8925f60fd9ec 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1341,10 +1341,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 @@ -1363,10 +1363,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; @@ -2092,9 +2096,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