From patchwork Mon Jul 17 16:55:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 13316011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DADEFEB64DC for ; Mon, 17 Jul 2023 16:55:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbjGQQzx (ORCPT ); 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 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 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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;