From nobody Mon Feb 9 02:50:57 2026 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 7FBC1C77B73 for ; Tue, 6 Jun 2023 07:08:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235848AbjFFHIy (ORCPT ); Tue, 6 Jun 2023 03:08:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbjFFHIw (ORCPT ); Tue, 6 Jun 2023 03:08:52 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id E23DCEC for ; Tue, 6 Jun 2023 00:08:50 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 24052180120BD8; Tue, 6 Jun 2023 15:07:45 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: Joerg Roedel , Suravee Suthikulpanit , Will Deacon , Robin Murphy Cc: jgg@ziepe.ca, kevin.tian@intel.com, vasant.hegde@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Su Hui Subject: [PATCH] iommu/amd: Fix possible memory leak of 'domain' Date: Tue, 6 Jun 2023 15:07:42 +0800 Message-Id: <20230606070742.139575-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" free memory of domain before return NULL. Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks") Signed-off-by: Su Hui Reviewed-by: Jason Gunthorpe Reviewed-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index dc1ec6849775..f08e65629c74 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2094,7 +2094,7 @@ static struct protection_domain *protection_domain_al= loc(unsigned int type) } else if (type =3D=3D IOMMU_DOMAIN_DMA || type =3D=3D IOMMU_DOMAIN_DMA_F= Q) { pgtable =3D amd_iommu_pgtable; } else { - return NULL; + goto out_err; } =20 switch (pgtable) { --=20 2.30.2