File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -540,7 +540,7 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
540
540
struct page * * pages ;
541
541
struct folio * folio ;
542
542
struct folio_batch fbatch ;
543
- int i , j , npages ;
543
+ long i , j , npages ;
544
544
545
545
if (WARN_ON (!obj -> filp ))
546
546
return ERR_PTR (- EINVAL );
@@ -564,11 +564,13 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
564
564
565
565
i = 0 ;
566
566
while (i < npages ) {
567
+ long nr ;
567
568
folio = shmem_read_folio_gfp (mapping , i ,
568
569
mapping_gfp_mask (mapping ));
569
570
if (IS_ERR (folio ))
570
571
goto fail ;
571
- for (j = 0 ; j < folio_nr_pages (folio ); j ++ , i ++ )
572
+ nr = min (npages - i , folio_nr_pages (folio ));
573
+ for (j = 0 ; j < nr ; j ++ , i ++ )
572
574
pages [i ] = folio_file_page (folio , i );
573
575
574
576
/* Make sure shmem keeps __GFP_DMA32 allocated pages in the
You can’t perform that action at this time.
0 commit comments