Message ID | 20230717165538.1542034-1-quic_bjorande@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1242589vqt; Mon, 17 Jul 2023 10:17:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlE9ThTsK1SFbW+bRELeia1d4kb0bPBOfz07Z3aMJ75t/Dg3gegZWLIxJL+cpjT9+gjmIPhn X-Received: by 2002:a17:906:e08c:b0:965:6075:d0e1 with SMTP id gh12-20020a170906e08c00b009656075d0e1mr9831817ejb.72.1689614265309; Mon, 17 Jul 2023 10:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689614265; cv=none; d=google.com; s=arc-20160816; b=VdbSbPPLeiHhCZLxzP7YBRN+5gltL0oCxlYtXAR4DlNX8JVtSr2JartCzY3dJKixhJ hyVyl4oFb3GvqGBU9fa0Jui1ObWdYl3VBi2Os9TeKxfNcBQEydwyC83TrPtQ0Nybn6TK HBRqpUKWY5EMcUXISFfPz3Hr6aNMKwYKYLQztUCwZyDMnloFwPkWJlX8W65fwLZ9MZC1 7B1vkqFxoZBjiykzfeltWeYiwDeg/8vZkRf0kMoHvjCv/zhmxs9ihXvt87PDZR0/A3fa ifujKl/Ng4cOhjJldX5LA1SXK5l5VFi1Yeq3YVievfowN3Ucl3CGR40t5KX0NyJH9gSs 1x3Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=N5jy5XjZt/vX6R3wNzoWbHctrUDLha8INP4r00L572E=; fh=PSF4sJxU0/jxjWhpCjNv8TULYRO9qVqjxUeTZwL+Qlc=; b=Ri9p1f9O/HuKHpcavH5dWBQn7Zf2WEzrp32UF5k4zK315G7joWKZoMh2m/0Pyg3XJJ z1qBsa8Kvcfdm+c34OvglDg7M9Y3PLX82keluZdGPtqed0nx3N1Ke6OUK9OODOw6jqmS 89/aDptES0i82jA9Qmiq0OuSi8bEn/+8ruJREHotQbcrb6g0FaigYwoziJ2TDk0DdDQr pi4URVEaqDuJ/TfeHX6eXOBSr3EvWRqYy4j5dzlUjfXXyoymxio0MSiRaizXCypaXJx1 jBZn4beQvxF1APWNRN1fe+HPtr9kBxZShpBLZlMrEK5p0msz+2hBLuzQfE0XaJkOHN0R GTdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YgDDmuPD; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n20-20020a170906b31400b009937e7c4e52si14190408ejz.558.2023.07.17.10.17.21; Mon, 17 Jul 2023 10:17:45 -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=@quicinc.com header.s=qcppdkim1 header.b=YgDDmuPD; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbjGQQzx (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Mon, 17 Jul 2023 12:55:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjGQQzw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 12:55:52 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19275E1; Mon, 17 Jul 2023 09:55:51 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36HClk98010196; Mon, 17 Jul 2023 16:55:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=N5jy5XjZt/vX6R3wNzoWbHctrUDLha8INP4r00L572E=; b=YgDDmuPDpgDKQTNymteWENn6SpkOLcw5y5VFFITtWdg/cs5DTZijA3q9yJ9K4zuvdXwK 7wh1ItCODt7/hJy9lYooIR3rGYfgLI2A5OhBWp1fJZ4RzfqwOafwpQbp6A62TGpsKM7w x8TDGGOZ+2hZYgDpntYm37ap320ArPbi/K4mq1GljCpbEZkx0a0gkGUcU9Bvz3cAVkZU n3eK1quSDNzWUN7ZsYPkkZbQPPmSIheMnpW2s5iCpRNJ6Yk0BOgKWbiqLWu9/KmJ+q8w f6SmT2wDbj7zqv+aHixMIPDRECWJHGo/XLX8tSKw4m9SWEpp0nyogd0kROtl05Rs4Yjn hA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rw33mh1sy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Jul 2023 16:55:45 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36HGtipx001534 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Jul 2023 16:55:44 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 17 Jul 2023 09:55:44 -0700 From: Bjorn Andersson <quic_bjorande@quicinc.com> To: Bjorn Andersson <andersson@kernel.org>, Mathieu Poirier <mathieu.poirier@linaro.org>, Sarannya S <quic_sarannya@quicinc.com>, "Chris Lew" <quic_clew@quicinc.com> CC: Deepak Kumar Singh <quic_deesin@quicinc.com>, <linux-arm-msm@vger.kernel.org>, <linux-remoteproc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, kernel test robot <lkp@intel.com>, "Dan Carpenter" <dan.carpenter@linaro.org> Subject: [PATCH] rpmsg: glink: Avoid dereferencing NULL channel Date: Mon, 17 Jul 2023 09:55:38 -0700 Message-ID: <20230717165538.1542034-1-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: QjqaYd_ZTCxU-2nFODrFdgrwY9tuuKIZ X-Proofpoint-ORIG-GUID: QjqaYd_ZTCxU-2nFODrFdgrwY9tuuKIZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-17_13,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 clxscore=1011 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 mlxlogscore=806 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307170155 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_BLOCKED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771688967840112357 X-GMAIL-MSGID: 1771688967840112357 |
Series |
rpmsg: glink: Avoid dereferencing NULL channel
|
|
Commit Message
Bjorn Andersson
July 17, 2023, 4:55 p.m. UTC
The newly introduced signal command handler checks for non-existing
channel and print an error message, but then continues on to dereference
that same channel.
Instead abort the handler when no channel is found.
Fixes: a2b73aa512a4 ("rpmsg: glink: Add support to handle signals command")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202307160800.sb7gMnL6-lkp@intel.com/
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
drivers/rpmsg/qcom_glink_native.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Mon, Jul 17, 2023 at 09:55:38AM -0700, Bjorn Andersson wrote: > The newly introduced signal command handler checks for non-existing > channel and print an error message, but then continues on to dereference > that same channel. > > Instead abort the handler when no channel is found. > > Fixes: a2b73aa512a4 ("rpmsg: glink: Add support to handle signals command") > Reported-by: kernel test robot <lkp@intel.com> > Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > Closes: https://lore.kernel.org/r/202307160800.sb7gMnL6-lkp@intel.com/ > Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com> > --- > drivers/rpmsg/qcom_glink_native.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c > index e10c05ed21bb..82d460ff4777 100644 > --- a/drivers/rpmsg/qcom_glink_native.c > +++ b/drivers/rpmsg/qcom_glink_native.c > @@ -1070,8 +1070,10 @@ static void qcom_glink_handle_signals(struct qcom_glink *glink, > spin_lock_irqsave(&glink->idr_lock, flags); > channel = idr_find(&glink->rcids, rcid); > spin_unlock_irqrestore(&glink->idr_lock, flags); > - if (!channel) > + if (!channel) { > dev_err(glink->dev, "signal for non-existing channel\n"); > + return; > + } I have applied this patch. Thanks, Mathieu > > enable = sigs & NATIVE_DSR_SIG || sigs & NATIVE_CTS_SIG; > > -- > 2.25.1 >
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index e10c05ed21bb..82d460ff4777 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1070,8 +1070,10 @@ static void qcom_glink_handle_signals(struct qcom_glink *glink, spin_lock_irqsave(&glink->idr_lock, flags); channel = idr_find(&glink->rcids, rcid); spin_unlock_irqrestore(&glink->idr_lock, flags); - if (!channel) + if (!channel) { dev_err(glink->dev, "signal for non-existing channel\n"); + return; + } enable = sigs & NATIVE_DSR_SIG || sigs & NATIVE_CTS_SIG;