Message ID | 20231213111450.2487861-1-harshit.m.mogalapalli@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7698508dys; Wed, 13 Dec 2023 03:15:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfn6qeTSmJ+2CC9ZKMR6m5JeoA2TBDTG/f7+y8K43odzyhlkgT28ACoTm4Pq6EjxVcNOwj X-Received: by 2002:a05:6359:420a:b0:170:4323:3249 with SMTP id kn10-20020a056359420a00b0017043233249mr6238224rwb.51.1702466148046; Wed, 13 Dec 2023 03:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702466148; cv=none; d=google.com; s=arc-20160816; b=EzwL4tXXbd2Kj8v7JiuK89bkL9m9rk9GS3TJymsIdmNiHsAyGbDMEImp+K9XUXd3HH r0JR7v4RdlpBVzMk90bG13o9DbcHg7Li6NkbOCGAu0B7+HdMhfrSuCtmo8D88eK3n7iR mPMvWkal+bGZh3hWTTZAShAABepq/1pByvDEYZ2WpafNadmnO2XCkDbMz6JlnFxsvf2G 9l9RWux8ygQhNUJt6B2axf7bik+F9FkZRxlO570hVL47b5k5ND2Ti6x1g8eA8qo6b0zM N4SBxNvVTtxqzJuNTNhSGv46Wf+zSmgiB3EiPsJ6Uj/F4X8RW5/h92mQHQn9RakA4ZjL l/nw== 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=mFa7+wZnRy8DezWqs2TWtFukUiLrknEYht2j11vwEQI=; fh=9eNoyDYsJYGi1Y0gwlPm2HKMyb+YwNMEaK/52kztWp4=; b=IuZqT5ai0NU6LALPiqgDlKRyeBpv17p4RKw0n5yWam8f+fwRLMMvcYuPof6LnQ7pIj u3zSVq93mV0xRclU5hTHQsq7bIKWn0N9x86anyFJwqbH85Elz92v/EVaeboQGzAsHMED wx1GMOUBvCaOyesrDhuR9NOw2DvPRbX5inLhlgCdJpcvESgU/e2xc3kDq6nyMTkprxTo 3CcMxY2vLG0glUrOjK75ikVEBys+qy23t3LRJwvxTswK+4aiRYeB6fkZ7CI21F0/Cw2l 5TGyY7ZKFyiFxl0eY3dud1YAJ61xmYzqhLpplHgbzUkFv75iitvVQ1u2MqMXlnw3lagR 7k9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=Z7VkBX9K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id 23-20020a630017000000b005c668dc2426si9424376pga.176.2023.12.13.03.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 03:15:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=Z7VkBX9K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4D5708045671; Wed, 13 Dec 2023 03:15:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377250AbjLMLPV (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 06:15:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233364AbjLMLPM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 06:15:12 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 524E8E3; Wed, 13 Dec 2023 03:15:19 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BD9StgE027181; Wed, 13 Dec 2023 11:15:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=mFa7+wZnRy8DezWqs2TWtFukUiLrknEYht2j11vwEQI=; b=Z7VkBX9Kp9KMSvBOM8UoEnTKH4b1RsQyEGFsiFP0xtts1NNu6P+6cIPR9KlNs1oCJvjg yp95QdfGi66FjjcH4sA6KFtXtdQTyDmF2HPdviZMAUYDHqwGBokOU6r0Ul+Bmn6jNZJy Wqj22nRblWG/KqTCOMyB4Zn8mHflkgeHYkjAh/0nALyzscPQY9oK5VwswGTTPmXXlVtG 10+J9KVCvrf1g3GEdcsvucvJNjRqCOazK2bIheqSFsU7Qk+lzzsbQtsncnVrou510ZpK FJGPjgLi5dpocJTpnK7zIhu8ImrVWV/NcndFM9ajDOPBDOmTa9v6FJd3KQn+IRZHTSiR wg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3uwgn3p7wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 11:15:04 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDB8pgV012799; Wed, 13 Dec 2023 11:15:03 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3uvep840j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 11:15:03 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BDBF2Ib002232; Wed, 13 Dec 2023 11:15:02 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3uvep840fw-1; Wed, 13 Dec 2023 11:15:02 +0000 From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Cc: dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, error27@gmail.com, harshit.m.mogalapalli@oracle.com Subject: [PATCH] iommu/sva: Fix memory leak in iommu_sva_bind_device() Date: Wed, 13 Dec 2023 03:14:50 -0800 Message-ID: <20231213111450.2487861-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-13_03,2023-12-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312130081 X-Proofpoint-ORIG-GUID: 0m8zQ4kmDUFzs7rwrZVMGrzKT8O08beB X-Proofpoint-GUID: 0m8zQ4kmDUFzs7rwrZVMGrzKT8O08beB X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 03:15:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785164732834030696 X-GMAIL-MSGID: 1785165143957385040 |
Series |
iommu/sva: Fix memory leak in iommu_sva_bind_device()
|
|
Commit Message
Harshit Mogalapalli
Dec. 13, 2023, 11:14 a.m. UTC
Free the handle when the domain allocation fails before unlocking and
returning.
Fixes: 092edaddb660 ("iommu: Support mm PASID 1:n with sva domains")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is based on static analysis with smatch, only compile tested.
---
drivers/iommu/iommu-sva.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 2023/12/13 19:14, Harshit Mogalapalli wrote: > Free the handle when the domain allocation fails before unlocking and > returning. > > Fixes: 092edaddb660 ("iommu: Support mm PASID 1:n with sva domains") > Signed-off-by: Harshit Mogalapalli<harshit.m.mogalapalli@oracle.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Best regards, baolu
On Wed, Dec 13, 2023 at 03:14:50AM -0800, Harshit Mogalapalli wrote: > drivers/iommu/iommu-sva.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Applied, thanks.
diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index 5175e8d85247..c3fc9201d0be 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -101,7 +101,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm domain = iommu_sva_domain_alloc(dev, mm); if (!domain) { ret = -ENOMEM; - goto out_unlock; + goto out_free_handle; } ret = iommu_attach_device_pasid(domain, dev, iommu_mm->pasid); @@ -118,6 +118,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm out_free_domain: iommu_domain_free(domain); +out_free_handle: kfree(handle); out_unlock: mutex_unlock(&iommu_sva_lock);