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 167CA6FA0 for ; Mon, 16 Jan 2023 17:08:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E817C433D2; Mon, 16 Jan 2023 17:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673888924; bh=LE/eE5UItzkVM3ncfNV0hBxL2FkEF5n2mHNN4XPbE2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gz1g5mIDux0BHMwHRied5HJIwS6HAsMgseSxk8jZOcYc2I3aBIs1pYI8DucGnnPaU Jwb6JMwpsssnm0yvNLSM+Nw6dMFm/v53SJ1eYtY95LQbvqgpGhBrrNqBwJPfpUoB6D weQolBG5Rg80hzlt9yUB7n+QexfRgtsW4deZ8+40= 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 4.14 192/338] iommu/amd: Fix pci device refcount leak in ppr_notifier() Date: Mon, 16 Jan 2023 16:51:05 +0100 Message-Id: <20230116154829.318631268@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154820.689115727@linuxfoundation.org> References: <20230116154820.689115727@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 7d94e1d39e5e..4449fa56f065 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -624,6 +624,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