Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2783006rwo; Mon, 24 Jul 2023 00:47:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFH6mgCgQiY0iLXo27SG9BCxaoKXuZkGAvsszJDygNhkqPSYc7SRJNSNR8WVzMqATN7Mwf5 X-Received: by 2002:a17:90b:3cb:b0:262:fba5:2a8e with SMTP id go11-20020a17090b03cb00b00262fba52a8emr8225420pjb.47.1690184851286; Mon, 24 Jul 2023 00:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690184851; cv=none; d=google.com; s=arc-20160816; b=kfHLak/HGrbD96D8dtJH77jQUrytQL7uhmwik6dU2vIhCScWvPJJuvw0JJ1j2iBb0V euCy0EimBh4Vqey1cVUakdVlzzL90sq3rtTm8LkYM7lWGZzHJ2tOCQGoo1NavINzVCr4 XFKuL+Lu6gbVXxRD6yu/OWfLyg+6AAYnEKMOTLRzeMmtaluXlDnnHIGNwuWXf8CWJUq4 6j5UG/jqc7WpRJlQE3xK5UXfV/IEwwPXZW8PF662Y9+otbn+tPoyAY2kJE4VyLs7oydJ wQYkBYIoKKYdcyN9pcNxWS5bBdBEwvqKmtRUn67xOZVqG2YSk0QLcQpPp628nH6RnCFH S0uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=8Pm/VR/5mlNa4De0nl8d+6zhJqVN5AlnV2B21swUrZA=; fh=TnMRDi3L0sQlniDGL1hLZ2IIl7MhP13XMPTS/HLyrTU=; b=FK79riREUJMQfgIwBdROEnJj1c2tYKAyEXNyoPUilQzdRyhDBen1qqS00mKupz9KDe AxmxopWGxH8XLUdhxEkHrbaDBUi13xlQVi6i72C628oCYtrSNg8+c0gAboEl2wRG89Sh lMH0Wutmlnh6dQfHkf08xa1awJ5wjaL+KTnMo6VuOzy3iM2ei9q072/4Mf78JuP0c4ET 8My4Rh+wryLkVCaerq4/YYVK7v4Oz8TkR4cekGDYfHw+j8LkXLr0fNg5BTWv4fXiKAG/ 9XRdmMmno85d/sQrYTVp9/XsceGLtDzeJhzxbFo5xIAkEGN3IcAfFBzAwxCWNE+e9MB8 eOrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=k92cUhmi; 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 gd5-20020a17090b0fc500b0025bb4a1c12esi354659pjb.148.2023.07.24.00.47.19; Mon, 24 Jul 2023 00:47:31 -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=k92cUhmi; 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 S230321AbjGXHJt (ORCPT + 99 others); Mon, 24 Jul 2023 03:09:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbjGXHJr (ORCPT ); Mon, 24 Jul 2023 03:09:47 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D60BD180; Mon, 24 Jul 2023 00:09:45 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36O60oWG012621; Mon, 24 Jul 2023 07:09:40 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-type; s=qcppdkim1; bh=8Pm/VR/5mlNa4De0nl8d+6zhJqVN5AlnV2B21swUrZA=; b=k92cUhmiBygkvx4QNXe034Q/miu0//WXL1QvCtZrTIjV3HNsgqXN5JCDBxiiTXGH9CMV HnuAgBuyrDkIZsdIe0/ycNF5pau06Rid7mZiVoLXxdy2BVhmXxR794eKjlB9u5uXeusd fB4vYFn/Ly7UwDznSkqkDNRXeu54nEPz8PXPXyrAmZlyVTX3Kw4p/JvCZGxrKE7oRXQI ljHXcdHPtm1pM1IsmIRXkEMM2Ej5smedXFyVDwvMGWAN9QXfP7yntvDfPW9Yq/SRPva+ kI0H7zOgwAul01KZ9Q83u3WsPqJYEEARmEiipXITaELJJqM7LKC3P+zLyiQSBntqU2RH NQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s07b8akrm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 07:09:40 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36O79dMn006488 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 07:09:39 GMT Received: from ekangupt-linux.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 24 Jul 2023 00:09:36 -0700 From: Ekansh Gupta To: , CC: Ekansh Gupta , , , , , stable Subject: [PATCH v2] misc: fastrpc: Fix incorrect DMA mapping unmap request Date: Mon, 24 Jul 2023 12:39:31 +0530 Message-ID: <1690182571-7348-1-git-send-email-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: fF3sXOt-28g5aqHbKrWvhp7f8YycG35q X-Proofpoint-ORIG-GUID: fF3sXOt-28g5aqHbKrWvhp7f8YycG35q 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-24_05,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240064 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Scatterlist table is obtained during map create request and the same table is used for DMA mapping unmap. In case there is any failure while getting the sg_table, ERR_PTR is returned instead of sg_table. When the map is getting freed, there is only a non-NULL check of sg_table which will also be true in case failure was returned instead of sg_table. This would result in improper unmap request. Add proper check to avoid bad unmap request. Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method") Cc: stable Tested-by: Ekansh Gupta Signed-off-by: Ekansh Gupta --- Changes in v2: - Added fixes information to commit text drivers/misc/fastrpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 9666d28..75da69a 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -313,7 +313,7 @@ static void fastrpc_free_map(struct kref *ref) map = container_of(ref, struct fastrpc_map, refcount); - if (map->table) { + if (map->table && !IS_ERR(map->table)) { if (map->attr & FASTRPC_ATTR_SECUREMAP) { struct qcom_scm_vmperm perm; int vmid = map->fl->cctx->vmperms[0].vmid; -- 2.7.4