Patch "vfio iommu type1: Fix memory leak in vfio_iommu_type1_pin_pages" has been added to the 5.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vfio iommu type1: Fix memory leak in vfio_iommu_type1_pin_pages

to the 5.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vfio-iommu-type1-fix-memory-leak-in-vfio_iommu_type1.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 54b54c0ea2034d4ef59099db1999040d6a6008df
Author: Xiaoyang Xu <xuxiaoyang2@xxxxxxxxxx>
Date:   Fri Oct 16 17:35:58 2020 +0800

    vfio iommu type1: Fix memory leak in vfio_iommu_type1_pin_pages
    
    [ Upstream commit 2e6cfd496f5b57034cf2aec738799571b5a52124 ]
    
    pfn is not added to pfn_list when vfio_add_to_pfn_list fails.
    vfio_unpin_page_external will exit directly without calling
    vfio_iova_put_vfio_pfn.  This will lead to a memory leak.
    
    Fixes: a54eb55045ae ("vfio iommu type1: Add support for mediated devices")
    Signed-off-by: Xiaoyang Xu <xuxiaoyang2@xxxxxxxxxx>
    [aw: simplified logic, add Fixes]
    Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index d0438388feebe..9dde5ed852fd0 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -693,7 +693,8 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
 
 		ret = vfio_add_to_pfn_list(dma, iova, phys_pfn[i]);
 		if (ret) {
-			vfio_unpin_page_external(dma, iova, do_accounting);
+			if (put_pfn(phys_pfn[i], dma->prot) && do_accounting)
+				vfio_lock_acct(dma, -1, true);
 			goto pin_unwind;
 		}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux