Message ID | 20221201040127.1962750-4-baolu.lu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp70931wrr; Wed, 30 Nov 2022 20:38:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf591YS2hzCkWgYwlvL6Qpns+x1XPUi/AKs9+BlE0gF8cKWzYfC4CffpPI8uzN/6VS0nitoI X-Received: by 2002:a17:90b:2d90:b0:212:ca73:4d6b with SMTP id sj16-20020a17090b2d9000b00212ca734d6bmr73587445pjb.16.1669869485157; Wed, 30 Nov 2022 20:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669869485; cv=none; d=google.com; s=arc-20160816; b=BREwADjNoz9jLn3uUAcQq6ZYoYPt3C+gHRx3Y2ntR03MOCwG+GtyvTTt5rHe7gsvn4 ufnftTJCaJyKOqmkeB3ME/7htkOgxKELWSYH2d2jLe3M1McUafKJF8PPSNo7rXpDKDHd OKSc3pODaUnfybQXMO40VjBW9wnCAjamkrIrMPV+TClWDAYOkyFkVaMGon88tuxZEDqH t7Xmp/ATAh6JHMkvEHDibZ/PVCQrWh8jfL5oZ+kPrvCBITd4W0vwkPGrwRRIYr89bsKS TLubz/b0Zk24UWetFexlEydQPw5KxKyu9XLqp+b3uCe8wXK/Tt5n2I61A9OiL7R5zLcZ ugCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WpwZklKjSi3+4wZZ8Wx4CYl0hORMywiQGd2p+SthXCM=; b=QCF6rYE+xD1xiftYg29lz5m4nH/WpnYJhKYkmZGKXwelPZ1NX9mZsV4TQosr2ZG4CX FOjnkuNf47vv7aDmudceUqYB1+GZ6rHTljqRl//um5INangZR8U6RbdLVqwUaWc/L1sc /8UllP+Y4ALWJpPE5TAX0DRG2CvsW2vBpvYQVggLVoG0eiphUI8W6gCDaauJoHOMgrvi SmLrv848gCtd1gXHGXA8DGvFkDj4GuqngdvC127Yn5QwfxeUH82XT7WVPaij6JJAg5Pr SPwa+BPNZP3J8OQ+sw8KmeNfJAPkzifkcPBW45LcprQYEYYPFhjelDAWMJnsxFSXjaB+ QVuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cYdAk5GB; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u25-20020a634719000000b004774c91af0dsi3094702pga.841.2022.11.30.20.37.51; Wed, 30 Nov 2022 20:38:05 -0800 (PST) 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=cYdAk5GB; 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 S229690AbiLAEJG (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Wed, 30 Nov 2022 23:09:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbiLAEIw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 30 Nov 2022 23:08:52 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 461FC77400 for <linux-kernel@vger.kernel.org>; Wed, 30 Nov 2022 20:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669867731; x=1701403731; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kjh7d4AzSK7GzAYNGRKUHRiJpGxHBkXpSkEPbEmZzzE=; b=cYdAk5GBVHy2QQTZyuY6oBUQm7e9/Rfch6UQh3OOPr8d+9rHGXB2zY/s mp2lmZoLihTl4qeeSiaNwo+jQDUDw5GB4ULttKV8l9jEE89PSBnetVpX1 fOpHKLxYgu9kR4S5vjhl7t2UCXdvNpCgNPHb9/D+3psx8AvbwjwB25UsI Nm57TJ7cE5elHSDhbYmDbSrg2JbdN29YhuewK3gO8rJLrt1B00UUzQ9v/ XUFFiXeFPaHy78vp96e9R/bsVCNLax9BG9esU5Ekpu14ZmmcmX4OnWSl7 oVtXWE1Wema4GeRGtkfgF4+Ig78hieyOTndWwRxm8T4prl18gVI3vl/ku g==; X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="377745755" X-IronPort-AV: E=Sophos;i="5.96,207,1665471600"; d="scan'208";a="377745755" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 20:08:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="707911660" X-IronPort-AV: E=Sophos;i="5.96,207,1665471600"; d="scan'208";a="707911660" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga008.fm.intel.com with ESMTP; 30 Nov 2022 20:08:46 -0800 From: Lu Baolu <baolu.lu@linux.intel.com> To: Joerg Roedel <joro@8bytes.org> Cc: Xiongfeng Wang <wangxiongfeng2@huawei.com>, Yang Yingliang <yangyingliang@huawei.com>, Jacob Pan <jacob.jun.pan@linux.intel.com>, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] iommu/vt-d: Fix PCI device refcount leak in has_external_pci() Date: Thu, 1 Dec 2022 12:01:26 +0800 Message-Id: <20221201040127.1962750-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221201040127.1962750-1-baolu.lu@linux.intel.com> References: <20221201040127.1962750-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750985065220822168?= X-GMAIL-MSGID: =?utf-8?q?1750985065220822168?= |
Series |
iommu/vt-d: Fixes for v6.1-rc8
|
|
Commit Message
Baolu Lu
Dec. 1, 2022, 4:01 a.m. UTC
From: Xiongfeng Wang <wangxiongfeng2@huawei.com> for_each_pci_dev() is implemented by pci_get_device(). The comment of pci_get_device() says that it will increase the reference count for the returned pci_dev and also decrease the reference count for the input pci_dev @from if it is not NULL. If we break for_each_pci_dev() loop with pdev not NULL, we need to call pci_dev_put() to decrease the reference count. Add the missing pci_dev_put() before 'return true' to avoid reference count leak. Fixes: 89a6079df791 ("iommu/vt-d: Force IOMMU on for platform opt in hint") Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Link: https://lore.kernel.org/r/20221121113649.190393-2-wangxiongfeng2@huawei.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> --- drivers/iommu/intel/iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 587eebe39820..5287efe247b1 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3873,8 +3873,10 @@ static inline bool has_external_pci(void) struct pci_dev *pdev = NULL; for_each_pci_dev(pdev) - if (pdev->external_facing) + if (pdev->external_facing) { + pci_dev_put(pdev); return true; + } return false; }