Skip to content

Commit a15e61f

Browse files
yanzhao56bonzini
authored andcommitted
drm/i915/gvt: Don't try to unpin an empty page range
Attempt to unpin pages in the error path of gvt_pin_guest_page() if and only if at least one page was successfully pinned. Unpinning doesn't cause functional problems, but vfio_device_container_unpin_pages() rightfully warns about being asked to unpin zero pages. Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> [sean: write changelog] Reviewed-by: Zhi Wang <zhi.a.wang@intel.com> Link: https://lore.kernel.org/r/20230729013535.1070024-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent adc7b22 commit a15e61f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/gpu/drm/i915/gvt/kvmgt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
172172
*page = base_page;
173173
return 0;
174174
err:
175-
gvt_unpin_guest_page(vgpu, gfn, npage * PAGE_SIZE);
175+
if (npage)
176+
gvt_unpin_guest_page(vgpu, gfn, npage * PAGE_SIZE);
176177
return ret;
177178
}
178179

0 commit comments

Comments
 (0)