From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1868E1863 for ; Wed, 28 Dec 2022 15:39:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92904C433EF; Wed, 28 Dec 2022 15:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672241979; bh=WDK+wlZh5yvlGL7avl8hWdqP7Kjtv9sRLBNWiO5fNVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wJH2Fy1r7ePaIPvipAYsQXmEtU6Z8JZ0bJI8BUfv+o4MgC5zLV2PazvURoW3j3uDk Jy909HXIsz3pEKGaS2uF1/Hb2qzURnDuF6MQOwUCwzisFUp+uWyn3G+VcyZQbvS+hm yB8RJXqb1fxfoTjFvcBcPyrnj5T06Ao/Eoo9Xkdc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Joerg Roedel , Sasha Levin Subject: [PATCH 5.15 549/731] iommu/amd: Fix pci device refcount leak in ppr_notifier() Date: Wed, 28 Dec 2022 15:40:56 +0100 Message-Id: <20221228144312.454859250@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144256.536395940@linuxfoundation.org> References: <20221228144256.536395940@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yang Yingliang [ Upstream commit 6cf0981c2233f97d56938d9d61845383d6eb227c ] As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it before returning from ppr_notifier() to avoid refcount leak. Fixes: daae2d25a477 ("iommu/amd: Don't copy GCR3 table root pointer") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20221118093604.216371-1-yangyingliang@huawei.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd/iommu_v2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/iommu_v2.c index a45c5536d250..c96cf9b21719 100644 --- a/drivers/iommu/amd/iommu_v2.c +++ b/drivers/iommu/amd/iommu_v2.c @@ -588,6 +588,7 @@ static int ppr_notifier(struct notifier_block *nb, unsigned long e, void *data) put_device_state(dev_state); out: + pci_dev_put(pdev); return ret; } -- 2.35.1