Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp590563rwi; Mon, 10 Oct 2022 04:53:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+xfbef8H889+WgzR9Jagj9cuE2E4yaxdyiwwRIhD5+BEu2jEvHNYSW6ts3Ztgt0ey//5w X-Received: by 2002:a17:907:8691:b0:783:645d:a4aa with SMTP id qa17-20020a170907869100b00783645da4aamr14403590ejc.473.1665402816234; Mon, 10 Oct 2022 04:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665402816; cv=none; d=google.com; s=arc-20160816; b=iWA8sl9SeubPDpXgMuLjwd7uIr2s5xQXY1rowAWp6z0CWqOIdLizxZg6ULqj7Vu2bm D+PgeyV1wxTO9aV9eWGtMekDtPgG9z4le4r1Wg2ra4RSiVqn0Ym/MSdwYZn1EmT6CnxX xAhKXmljbDc/+S9pYkmFBNllemNZ2wJj7QuHtCzG8/ItsMTOArW7JcLP63cFk79SnRiY ckaBdj81HbBttNVhjIdJIWMK01JHD0UuHduaGRB0+h6VMHI+91OSHc39hQUwfEt29mEd GbP2hgl/IEj4+UNFePkpFvZDGzP1z4wu4vKCO14Q0TX25GFKrzUjF9tEnfU7NKGbZVXt H6DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:to:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=B2wwxZ7KHLXURh+rvuglwE+KYVm/8PC2Nk9tIih6iAg=; b=elrPnF/VCgF56bYriEs3OELw94I0WDF0BbNg3e5IWK8u5WhFoTv9G/4j/nbsc0+OLD tqwk6Y9Q8nvncZqMvKbc5stbZ3XRi2vwCdV5ASm89cXjSApeWjAPUsPx0dgZp8A7mR1b tzmTMg7RLbDEecDq0PmXk1eKHsVdcmgzcsLTivSMTgOuLsbMyF+b4H9FUiKIe/lg8PYg ysd2b8IPHPvsgwKoqOhuDbA9J60X278QgmuCbr4jyOJsh7CeeM077tmPxntXQJtR7I1l 5RNWUgROM6HgIRXxtekr6hFGDSwpQxnAWn7KgGqexElvl3b5pWpFJVlDAaU6nfxgZsBE b++A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jdgK3qAv; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a50d58b000000b0045713c5c784si8686893edi.127.2022.10.10.04.53.11; Mon, 10 Oct 2022 04:53:36 -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=@intel.com header.s=Intel header.b=jdgK3qAv; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbiJJLdh (ORCPT + 99 others); Mon, 10 Oct 2022 07:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbiJJLd0 (ORCPT ); Mon, 10 Oct 2022 07:33:26 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048636F567 for ; Mon, 10 Oct 2022 04:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665401590; x=1696937590; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=VOeaJcpwzZJ0pJxWdJglMMEshugCfS9igKMdjRFdHpY=; b=jdgK3qAvy9zp8VPJfmi5KoCYRsqrWOpYHaOxQIHDmx50oFkaffCavhZr qM9SA/+6ooM9e0vU9MqRKzlzxlzkcKnTWRn5PM7TKfuO+KA+KS1j7v9Bi FwiyBBeGbPtdeQqZx3YV9KWLUzHjCIC6diP9X7XKoT+HQbY1UXl/QeVhC /1EJ/KOM8DbLUrnyGQ6LlRImzj+5uyx0Jthw8c6M5quRU6yzkLUKduZPR XBMLzwKro+8+e19d3z4QVr+K34GAHMQGO3eGDWbc4trwxjkKHJu7uluaS myqVnVQllHw+dWI60YolJhvjbzc5AIHQvTS8U4tNql3nPF90JeNxFYRim A==; X-IronPort-AV: E=McAfee;i="6500,9779,10495"; a="287440646" X-IronPort-AV: E=Sophos;i="5.95,173,1661842800"; d="scan'208";a="287440646" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 04:32:47 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10495"; a="688754888" X-IronPort-AV: E=Sophos;i="5.95,173,1661842800"; d="scan'208";a="688754888" Received: from jbai-mobl.ccr.corp.intel.com (HELO [10.254.211.42]) ([10.254.211.42]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2022 04:32:45 -0700 Message-ID: <35cf84fb-7672-671a-4354-0fb66bd2f8e7@linux.intel.com> Date: Mon, 10 Oct 2022 19:32:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Will Deacon , Robin Murphy Subject: Re: [PATCH] iommu/vt-d: Clean up si_domain in the init_dmars() error path To: Jerry Snitselaar , iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20221010065608.281860-1-jsnitsel@redhat.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <20221010065608.281860-1-jsnitsel@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_NONE 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 On 2022/10/10 14:56, Jerry Snitselaar wrote: > A splat from kmem_cache_destroy() was seen with a kernel prior to > commit ee2653bbe89d ("iommu/vt-d: Remove domain and devinfo mempool") > when there was a failure in init_dmars(), because the iommu_domain > cache still had objects. While the mempool code is now gone, there > still is a leak of the si_domain memory if init_dmars() fails. So > clean up si_domain in the init_dmars() error path. > > Cc: Lu Baolu > Cc: Joerg Roedel > Cc: Will Deacon > Cc: Robin Murphy > Fixes: 86080ccc223a ("iommu/vt-d: Allocate si_domain in init_dmars()") > Signed-off-by: Jerry Snitselaar > --- > drivers/iommu/intel/iommu.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index 31bc50e538a3..8f1f80a4d0c5 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -3042,6 +3042,8 @@ static int __init init_dmars(void) > disable_dmar_iommu(iommu); > free_dmar_iommu(iommu); > } > + if (si_domain) > + domain_exit(si_domain); Thank you for the patch. Above requires si_domain to be NULL or a valid pointer. So do you also need to add the following change? --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2410,6 +2410,7 @@ static int __init si_domain_init(int hw) if (md_domain_init(si_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) { domain_exit(si_domain); + si_domain = NULL; return -EFAULT; } Best regards, baolu