Skip to content

Commit 4518e5a

Browse files
lrq-maxawilliam
authored andcommitted
vfio/type1: Fix error unwind in migration dirty bitmap allocation
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: d6a4c18 ("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>
1 parent 089803c commit 4518e5a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int vfio_dma_bitmap_alloc_all(struct vfio_iommu *iommu, size_t pgsize)
292292
struct rb_node *p;
293293

294294
for (p = rb_prev(n); p; p = rb_prev(p)) {
295-
struct vfio_dma *dma = rb_entry(n,
295+
struct vfio_dma *dma = rb_entry(p,
296296
struct vfio_dma, node);
297297

298298
vfio_dma_bitmap_free(dma);

0 commit comments

Comments
 (0)