Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5845524rwp; Mon, 17 Jul 2023 10:15:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFXnmh2KZUH0WPl6FS3VV9oontflhxWUcSpHLOSrlWL4gzZLWUVPbmQc0Vrw5DMyUzoZSV7 X-Received: by 2002:a2e:7310:0:b0:2b7:364e:91ec with SMTP id o16-20020a2e7310000000b002b7364e91ecmr8830443ljc.13.1689614152620; Mon, 17 Jul 2023 10:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689614152; cv=none; d=google.com; s=arc-20160816; b=nxvS0t2ouANcx1YAz4oZH8FgaKNyNvJoQEB7EfHKuRqsvOv1uWN8+yfukifmY65YDQ mrcvjDc3vrFIa4XyyN96TAYSPL2hcSBBiaXtHgnQBhKqzdlstyyN4O79mUM1nZZ1gDBb LdFUzLtQi3Illcb9FYK6ksCV4hdC+XLDWkIulscsn9hsT3FvN9BzzQEGsNA+aqJ3w160 eTlZ3elFMycX7bBMMw0M3ojcocl3PnhW28ddHnEn70bvK2tUrYxe5+OXzOLx2U8bMTIw 6hZMqAClSM++wuLUAyEdBKup1VB16M89trtiFd+2OpgXNlqCACNiCXtx99gGMCjjudFS 8pyQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v20-20020a1709061dd400b00992a9bc7432si13637882ejh.936.2023.07.17.10.15.26; Mon, 17 Jul 2023 10:15:52 -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 S229687AbjGQQzx (ORCPT + 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 ); 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 To: Bjorn Andersson , Mathieu Poirier , Sarannya S , "Chris Lew" CC: Deepak Kumar Singh , , , , kernel test robot , "Dan Carpenter" 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202307160800.sb7gMnL6-lkp@intel.com/ Signed-off-by: Bjorn Andersson --- 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; + } enable = sigs & NATIVE_DSR_SIG || sigs & NATIVE_CTS_SIG; -- 2.25.1