]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vfio/type1: Fix error unwind in migration dirty bitmap allocation
authorLi RongQing <lirongqing@baidu.com>
Wed, 21 May 2025 03:46:47 +0000 (11:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:11 +0000 (11:07 +0100)
commitf0af7f7ffcf56fb8676a4f0e79e086e1b73413b6
tree5569235bfed4f5adbb4125a4681f73cd2116b782
parentfed9f0c1239b3540ca42811ef1a786c74938569c
vfio/type1: Fix error unwind in migration dirty bitmap allocation

[ Upstream commit 4518e5a60c7fbf0cdff393c2681db39d77b4f87e ]

When setting up dirty page tracking at the vfio IOMMU backend for
device migration, if an error is encountered allocating a tracking
bitmap, the unwind loop fails to free previously allocated tracking
bitmaps.  This occurs because the wrong loop index is used to
generate the tracking object.  This results in unintended memory
usage for the life of the current DMA mappings where bitmaps were
successfully allocated.

Use the correct loop index to derive the tracking object for
freeing during unwind.

Fixes: d6a4c185660c ("vfio iommu: Implementation of ioctl for dirty pages tracking")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Link: https://lore.kernel.org/r/20250521034647.2877-1-lirongqing@baidu.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vfio/vfio_iommu_type1.c