From patchwork Mon Jul 24 06:40:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 124656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1624264vqg; Mon, 24 Jul 2023 00:18:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlExRb34tZlWWis7x1j2+GAAqwxwE1/YQichR97lh2RQ9JL6tyc6PdJEfX3bqtFmE55nCgVV X-Received: by 2002:a17:902:e5d1:b0:1b8:8b72:fa28 with SMTP id u17-20020a170902e5d100b001b88b72fa28mr8474867plf.58.1690183096990; Mon, 24 Jul 2023 00:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690183096; cv=none; d=google.com; s=arc-20160816; b=UO4LX+CMEgUN5oSugq3esAVPITgBaFOugdny0dv2LZNxzY3GJUC8HLI4PRICqJKOK2 uhqpBU8oXMoD7v+84Bm0EgZm9fs17wERxKmmHhJYKOfWcDfcKBjTBlPhSZiH52voNs+g 1lxvYXvUOFGH2MdG0jLC7r0L1Y16ocKJ3Ly6qVkRYdaLBj5dM8FhFzY9BAuOzflC/tBK cCtMS9hLDoltgpezA0GFORd7oT4ytejfHLZ437RUExurAIm4gC13QzqrN6XZZK9R8L2E lW+UrVa/W618rFB8CHlxZg7aPe975vsOtUvIScKNg+UpXawXif8S5vDlWMFyXYS0Um3q ZFAw== 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=Mc3R7gr8b0wW/aOuh3E1QVKbuciMTZGd7zB0cOAwXb0=; fh=O89gU8TaI8Vvi776drJhcCy3jy1Ps7gqRKp2e21JGME=; b=oWJNQrxdaofpqn8FjiTliowM6MKUoFqUCSwVDjMxMTdwKJyRBcq/zRHqaCX8Rl4LfV kKz9DZ3v/PhnPuDAsID81Q1iOeVTCWnzoNgGAXVkd6t03i2Sn692qlDmNUOPTkH6sHnz 1EaW88eRIfJiYULBRN7C3FXkcnnPQ7FHccYDH/L/jNuZxy2PJ/76YWMzzxDh+DoIEOlU WaAxKBG7hUDVpM/UYKyiF0NGXF4vFyrODeHBODOWkxfGrmWkULW57vEvkXA76GnO+mwe mP4soOwBk5T3Zoe4csVggFDIdjmH9huuHCR2qENlyiOSVEriirqD3MXdvsU6/qsIrE3B qa7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=aeXnX8fq; 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 z4-20020a1709027e8400b001b876d46162si8105354pla.38.2023.07.24.00.18.03; Mon, 24 Jul 2023 00:18:16 -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=aeXnX8fq; 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 S231172AbjGXGmi (ORCPT + 99 others); Mon, 24 Jul 2023 02:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231147AbjGXGme (ORCPT ); Mon, 24 Jul 2023 02:42:34 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54E1FA; Sun, 23 Jul 2023 23:42:01 -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 36O6RhQ6006304; Mon, 24 Jul 2023 06:40:41 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=Mc3R7gr8b0wW/aOuh3E1QVKbuciMTZGd7zB0cOAwXb0=; b=aeXnX8fqm/OM/RUNPY2yW/DhOZk19DAW4pN98bAovz0KvXiIupYkhAnYCeEWLdD2PCzy mYBDpT8oOgUf85JHzoD8SBL95jlju98vsrysFeilIMw6sdPTJdHKRuf25DUniu0KPpAY bDQkw7Woo8Tuck2ps2ei40FOqJHvnkTAK+v9zonTD0Szn6X384t59vy9TQvKhgVHxGeE RW6yJgN+5MZpnwt2lL3ct/TvlJ8qapDVP01lXLhGG7OIO4r3zSKCIyoNgx5XKEWnpxMx KX00QY3fOQyssfw0kuCRqDLwrwiy8rgsglnHKjFhB/DBV1noF1IIrUMujCXTjkgLKqdD KA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s07b8aj7u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 06:40:41 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 36O6ednZ027165 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Jul 2023 06:40: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; Sun, 23 Jul 2023 23:40:36 -0700 From: Ekansh Gupta To: , CC: Ekansh Gupta , , , , Subject: [PATCH v1] misc: fastrpc: Fix incorrect DMA mapping unmap request Date: Mon, 24 Jul 2023 12:10:27 +0530 Message-ID: <1690180827-20810-1-git-send-email-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: hQlpGyzUNz7_wlk5ac2x1r_q48o8zMkR X-Proofpoint-ORIG-GUID: hQlpGyzUNz7_wlk5ac2x1r_q48o8zMkR 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_04,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 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-2307240061 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772285431033319856 X-GMAIL-MSGID: 1772285431033319856 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. Signed-off-by: Ekansh Gupta --- 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;