From patchwork Wed Dec 28 16:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970212wrt; Wed, 28 Dec 2022 08:20:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXusw6TU2xs3i0NZzwjKFsv6aqOpxxWwcbVuveRgwfRlhU+m303qLq9lnWfbcXRbzyIftvii X-Received: by 2002:a05:6402:685:b0:46c:e558:ce60 with SMTP id f5-20020a056402068500b0046ce558ce60mr21907359edy.22.1672244403409; Wed, 28 Dec 2022 08:20:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244403; cv=none; d=google.com; s=arc-20160816; b=UrOCzF2u+zfeKeulrd04A7SZgVY8dWRhmeEPUlL6hxYY+9jUj+VNdky0RzgJF5yfJX Jbg9ZefA5Mil9zSmqImv8JZ2Lbigj5DBmfsJUwzTazcW1ZmLLvirixI11lKqOL2+dtNT tz0QPAiufKd1q6CUZDmVG5ITzZjP633FWS+offzXoK+SjDjzuqHVxNDL7lDnmd/cy5Ln 0SgXWdPKuVIe/trTMNsLvwe1f6DzzP8GFetxfe3pa3E6V2JO55+VekO1/ObtVvz1fmoL BXQI3IxS2NDVK0M7z4gEI1wwo8FRN0yqDUOUhcLSG/vD4fEiD//7OHRXXXc4ApaY2ZGK n2yA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nCFU0KCqTh7FlQ8evG955AiRt86XIvSnki+8nWo+njQ=; b=w950BUZQ3l84aF9U5/DDJHJrtWvM8xx01ozfW9ymlcRbAOS5Zs4e0E5Fq9/Cbx2JlV p1fZA8P0qh8IMA7OupwXYAZPpSefvX/Ce9GFb7dQRaKo3iUB6IHbo6d0EVt6W22BFHpH cQl5aQi9ptwACRL4shUs/iEp9DRlB35gylUJqNZf/Smf6lMLK4LyDWvunEi//hg3cHru 6fMT1zTTdgx/QyXtl9fRiazv3wY13Gw2ZvePk7YDa1FOruP7dfYWlWrGsedIiKtwo9kX FqDgGgXXg6RVUGNe7ScUe58PZ29c8/2a3DP04MGzr7sixr2FiihP2rCuLQNtjcaF/C52 C5kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GC4TcWpB; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a056402048600b0046fbd084ea6si11889870edv.142.2022.12.28.08.19.39; Wed, 28 Dec 2022 08:20:03 -0800 (PST) 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=@linaro.org header.s=google header.b=GC4TcWpB; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234637AbiL1QTW (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234438AbiL1QSo (ORCPT ); Wed, 28 Dec 2022 11:18:44 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DBF19C16 for ; Wed, 28 Dec 2022 08:17:27 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id c8-20020a17090a4d0800b00225c3614161so13303097pjg.5 for ; Wed, 28 Dec 2022 08:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nCFU0KCqTh7FlQ8evG955AiRt86XIvSnki+8nWo+njQ=; b=GC4TcWpBQl00n4Y1fqaF8bTVq2/KnhyWyJ3s4AMB8/9MIP9ntBMY0TWweRIge8i1EQ lk4F1KiY+FtYLf2e7QqDESspd2fPqQoqPNNvhGinnvehLQ2M9LZ5gT14gT+7XcyvXzT1 rx1YJowuaJrw3OYziAYFJwAWOdKSo27bKmzAg4SM8exV+5Jp7tTRJTK2YN9Db2TJjIO6 KKXS2G8qz4MkJT+3Ky6SZklbrn/zo9a7xZbs5o49mRBSE7+5f6yy0+XiHzlBrlJNX9yW 3DgOnA3pjb+V1nngG6/WLfY/BaSWyelZpfesVsTNQPHd/iJFXocVBjkq7J//BxUxSsDv jMQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nCFU0KCqTh7FlQ8evG955AiRt86XIvSnki+8nWo+njQ=; b=laV8NmdiXGPp9wNbzeRMSJOH6jDVQRR+7ur6ENMx28nU9ktPhQlxFQkNnYlhn6OTKW p2IBTxYcm9b6kLoxyeuWks5G21jwcAPjn3FxgylhHsuSenLuBB/a5VHXkmx9TdaGteYY ugtjvzHRQGF6aLLjWx8YSoDgrVvhfWPQxpyvIHAnpuoIE851fZo5BgcuLkspRtYrVWFq p5R4PN04alCVIWHNPUfVuxiC9gDjm/YD6uXOpnXt21/MzIlBOw8y3wlf7HEoMsWRyGFt UASgUGA6q87b0WlFt7HUMDaL8G5FZH+rixOSi3MFxk/9cp1A27qcWw4PbRJ49nPi7G9u 9HIg== X-Gm-Message-State: AFqh2kp9xRWH29yzr/SUJ071bSB+Rui8A0hQ+xKnP6+IdTi1gGSutq6q 6JHcWUO6sclzD8ZcLxVfoR/a X-Received: by 2002:a17:902:b401:b0:189:aa51:e27f with SMTP id x1-20020a170902b40100b00189aa51e27fmr32379244plr.44.1672244246949; Wed, 28 Dec 2022 08:17:26 -0800 (PST) Received: from localhost.localdomain ([117.217.178.100]) by smtp.gmail.com with ESMTPSA id s3-20020a170902c64300b00186abb95bfdsm11256798pls.25.2022.12.28.08.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:26 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH 3/6] bus: mhi: ep: Only send -ENOTCONN status if client driver is available Date: Wed, 28 Dec 2022 21:47:01 +0530 Message-Id: <20221228161704.255268-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228161704.255268-1-manivannan.sadhasivam@linaro.org> References: <20221228161704.255268-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753475347453873162?= X-GMAIL-MSGID: =?utf-8?q?1753475347453873162?= For the STOP and RESET commands, only send the channel disconnect status -ENOTCONN if client driver is available. Otherwise, it will result in null pointer dereference. Cc: # 5.19 Fixes: e827569062a8 ("bus: mhi: ep: Add support for processing command rings") Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 8b065a3cc848..7d68b00bdbcf 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -203,9 +203,11 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele mhi_ep_mmio_disable_chdb(mhi_cntrl, ch_id); /* Send channel disconnect status to client drivers */ - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + if (mhi_chan->xfer_cb) { + result.transaction_status = -ENOTCONN; + result.bytes_xferd = 0; + mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + } /* Set channel state to STOP */ mhi_chan->state = MHI_CH_STATE_STOP; @@ -235,9 +237,11 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele mhi_ep_ring_reset(mhi_cntrl, ch_ring); /* Send channel disconnect status to client driver */ - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + if (mhi_chan->xfer_cb) { + result.transaction_status = -ENOTCONN; + result.bytes_xferd = 0; + mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); + } /* Set channel state to DISABLED */ mhi_chan->state = MHI_CH_STATE_DISABLED;