From patchwork Wed Dec 28 16:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 37230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1970378wrt; Wed, 28 Dec 2022 08:20:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXuThVioTMzCq49f5r+NaSesEQKw2bV8chgmahxSrL4hgTQxLeTNAxGW2NezBhYwSvlA/p4s X-Received: by 2002:a05:6402:4518:b0:46c:b2a7:1e03 with SMTP id ez24-20020a056402451800b0046cb2a71e03mr18979952edb.36.1672244428531; Wed, 28 Dec 2022 08:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672244428; cv=none; d=google.com; s=arc-20160816; b=eB0CrWOu/iub6mMrqR5w82OJPsz86oIy02JTb05JMccWz1or3VdZHBqBGcrHBHUwVt 9GFXDejF8Z4nUnkOHAkpTbqX3VgvPMjwroYzB/eqNhE7LibLWHA1y21HRSUiRQV1OFe4 5hTFXZEvmu9dSe/h5kKuYrjLZEJo8ozhe62r4zrUg0IqRCWAuw8N/W2dc1WbsoT/SATE e6ivTHWqv7G4OarBcjJt1KTchnC30u5VFdQXeznkO13la2+1o6mZjn5zywLmEdMJm8/2 xIuX11NrLTo8n43QHIQYcpGe8u5HeyOnpzYMz3w4tFClzK/kkzoVMRga3jvUiSKPfRm5 E7cg== 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=cTBEJ8Yt1F+qFY4dSzBFOLsJDCyD/sILn8NSazfFNCk=; b=E1mxfV1pAvRGBzixqKTyHNHFbmKqg0M4uK+RBRNycunpAGRC7BY1Frf323nBJQv+vs t99D03Qxxxlh6JpBsvyBfgLwzwaWdof+smOnhnYJRrkiPiJqfXLyzae7AkIRMepWBrdh vgT7wuZJmljNQbNla8R/aNRx7F2jN+LrZD2INQ6vbXqR4Xutk0pEcreH4xPu2UMENYvQ iGcQpzdM6OaVEPcJb4PgnFS/U1R/cEJhAs79q0ydVskImQQSkrt/8oQ/mRNyBVuwRaL7 jjGsfotWpMWZbKOgjnsREU5HhJz8+pye2ngg+TcVDzy61nqh09tyikMML7ELlrd5eX/n //TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dj/Ub+3k"; 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 g12-20020a056402090c00b0048017a9576bsi13593129edz.543.2022.12.28.08.20.04; Wed, 28 Dec 2022 08:20:28 -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="dj/Ub+3k"; 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 S234571AbiL1QTT (ORCPT + 99 others); Wed, 28 Dec 2022 11:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234439AbiL1QSn (ORCPT ); Wed, 28 Dec 2022 11:18:43 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE2619C0C for ; Wed, 28 Dec 2022 08:17:23 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so20455600pjj.2 for ; Wed, 28 Dec 2022 08:17:23 -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=cTBEJ8Yt1F+qFY4dSzBFOLsJDCyD/sILn8NSazfFNCk=; b=dj/Ub+3kYN0/agt2gS0Famnp0N3dkHl3+FQoEtgK8tVZZmkz0cvmZhpxMoXa1eohso W/q7ffJ3CL2rdK75bB9J1pelQS2Gl7fVyTt/u6b0c2MzkYmsDpSLTJ+n5S/PkQMVpxpg W3tx3uGeOsiW3kipxMk+3R6nTT0sfKA0ROiAjB2bdYkF6U4xG1RWl8CKDDbnBLmgQu/n ACSEHvnEFfsHMdlRyJjvYR5Q2ywytVYCohuJfc9xu46q4Lyb2vvy+gNZ4T48sjPzEgg/ ayNGNThqpMWVae/tFgumbIJFspGofWHAyjI7Q3rCIajcGJPV2nFAxsQnkr1zhMyVlz8H 8Gyw== 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=cTBEJ8Yt1F+qFY4dSzBFOLsJDCyD/sILn8NSazfFNCk=; b=BQY+RNsVhWZ1XTW/ynN+Yl1/upJi1NKbJyo3Zsb877a2FoddJW9ZKOWPTQwcRTI6b0 xl7DiiR3AewZ17j86VSbWnaHOpfpUMv1c/2G1STvSfF7GKd8VNr/vKbwlcjd/9ZkoBum 6K+IDFYxnpYvAZ3vAeT6sRwKBPnYuF2gm+fT8NXspif5XG3I+Ds7svkPztp8cfPMztpH KFVYbFEdMqlgQgxigG3UGEFVNaOz0yOKfiLDH5siKfgkx9S22LRflRPl93j5E79nOb8g y63u/+QWp+Yl+whXfMz1GFJGQJspjRCrkPPy1ctF4nEEChes+nyiDAXoIriPwokHFECu Nd6g== X-Gm-Message-State: AFqh2kqb0mk7ty63r4CbjHstYhqxkQEqNWDsmoMDbbrLMnJFKDBjwcrc PHIdC1gYRIbiiclmB5Wp0ZeW X-Received: by 2002:a17:902:cecf:b0:191:191f:e7a7 with SMTP id d15-20020a170902cecf00b00191191fe7a7mr36963609plg.69.1672244242997; Wed, 28 Dec 2022 08:17:22 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:17:21 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller Date: Wed, 28 Dec 2022 21:47:00 +0530 Message-Id: <20221228161704.255268-3-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?1753475374099464439?= X-GMAIL-MSGID: =?utf-8?q?1753475374099464439?= Before processing the command ring for the channel, check if the channel is supported by the controller or not. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Jeffrey Hugo --- drivers/bus/mhi/ep/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 55209d42a995..8b065a3cc848 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -123,6 +123,13 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele int ret; ch_id = MHI_TRE_GET_CMD_CHID(el); + + /* Check if the channel is supported by the controller */ + if ((ch_id > mhi_cntrl->max_chan) || !mhi_cntrl->mhi_chan[ch_id].name) { + dev_err(dev, "Channel (%u) not supported!\n", ch_id); + return -ENODEV; + } + mhi_chan = &mhi_cntrl->mhi_chan[ch_id]; ch_ring = &mhi_cntrl->mhi_chan[ch_id].ring;