Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6706170rwd; Tue, 6 Jun 2023 00:18:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48emTK7EkFIdcG0vE/ny+Yad3W7FFuceE1XJC9Unw+l4L319KgOnRklrlpl8aZKubrwo9k X-Received: by 2002:a05:6a00:b81:b0:643:96e:666b with SMTP id g1-20020a056a000b8100b00643096e666bmr648137pfj.34.1686035894188; Tue, 06 Jun 2023 00:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686035894; cv=none; d=google.com; s=arc-20160816; b=ijjRJBahp2vDePwDb4HNWiLG35jo8vQB+jBNF80/8VVBtdzYCiZubIpkyegX/qq76S +uxeFs7nt0sl7cuXt0J9OAOPGfkMJ+KD2QUn9OqDMQXBDhvISI9omV/SQiVePyD3IUnu Y1mk1fSPRfv3d9so1RcVgtPEwMKAn/B+s3oO5m5/fmoMpP47GVtWDEyJkOX3M+v2JMI7 U/7uh9hciWZ65qe0ooM+wxp4FUioXISp1hm/WQLZ42be2xqWTaQnmH6/9CY+MGtQ94ND e6tOirufUDjEn09dDmxmhsSUFbjGrrcwMxvJsD6+uE+uv9Uj4ylnspbgUfpc6i5jgTCI AQjQ== 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; bh=2QZSDDZacFGv2IkhrKnByvn0X+f13YNbBf6qCoI3NJY=; b=pbbaUVSSsWbUbbdEDC5FKKGcB3/eqJF8pwmYil+TiHfIUrkj79JRo34gZsGvICUwer t6YofgEaskUl2/ex7kItsHZ5UNvdzuc0yc1eOG2w84Q22ha42sIdNnZzKqG+wtVWk1Xd /hofGpjw6UWL0gzwzePidKiaRn/dkh2xHNrTPESGP1LR5w4Vq3vNqjCrBRwa9eQDaLrg e9GmNlXixLLfTr4ZHeF8Az6RI1J4FIL4RgSZyQ9PZMZAsMlR+OkAGtMLSj1x35GDjyKL Lb4chW5+tAUfkDOFKkTmYH1Q2TLd19uRx64WKmU/KREMGbUXmnCg+CYlQ8pFqL+iV0oG qsDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k27-20020aa7999b000000b0064d411989a8si6799981pfh.46.2023.06.06.00.18.00; Tue, 06 Jun 2023 00:18:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235842AbjFFHIx (ORCPT + 99 others); Tue, 6 Jun 2023 03:08:53 -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: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 free memory of domain before return NULL. Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks") Signed-off-by: Su Hui --- 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_alloc(unsigned int type) } else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) { pgtable = amd_iommu_pgtable; } else { - return NULL; + goto out_err; } switch (pgtable) { -- 2.30.2