On Fri, Jan 30, 2026 at 11:49:27AM -0800, Matthew Brost wrote:
> drm_gpusvm_get_pages() only sets the local flags prior to committing the
> pages. If an error occurs mid-mapping, has_dma_mapping will be clear,
> causing the unmap function to skip unmapping pages that were
> successfully mapped before the error. Fix this by forcibly setting
> has_dma_mapping in the error path to ensure all previously mapped pages
> are properly unmapped.
> 
> Fixes: 99624bdff867 ("drm/gpusvm: Add support for GPU Shared Virtual Memory")
> Signed-off-by: Matthew Brost <[email protected]>

Reviewed-by: Francois Dugast <[email protected]>

> ---
>  drivers/gpu/drm/drm_gpusvm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index aa9a0b60e727..d733599ceb9a 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
> @@ -1572,6 +1572,7 @@ int drm_gpusvm_get_pages(struct drm_gpusvm *gpusvm,
>       return 0;
>  
>  err_unmap:
> +     svm_pages->flags.has_dma_mapping = true;
>       __drm_gpusvm_unmap_pages(gpusvm, svm_pages, num_dma_mapped);
>       drm_gpusvm_notifier_unlock(gpusvm);
>  err_free:
> -- 
> 2.34.1
> 

Reply via email to