[PATCH] drm: use size_t variables to iterate through pages

Jordan Crouse jcrouse at codeaurora.org
Tue Oct 3 15:38:11 UTC 2017


drm_gem_get_pages() and drm_gem_put_pages() calculate the number
of pages to operate on from obj->size which is a size_t.  Use
similarly sized variables to calculate and iterate through the
pages to avoid possibly losing bits from the page calculation.

Signed-off-by: Jordan Crouse <jcrouse at codeaurora.org>
---
 drivers/gpu/drm/drm_gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index af62017..a8c146d 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -550,7 +550,7 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
 {
 	struct address_space *mapping;
 	struct page *p, **pages;
-	int i, npages;
+	size_t i, npages;
 
 	/* This is the shared memory object that backs the GEM resource */
 	mapping = obj->filp->f_mapping;
@@ -603,7 +603,7 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj)
 void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
 		bool dirty, bool accessed)
 {
-	int i, npages;
+	size_t i, npages;
 
 	/* We already BUG_ON() for non-page-aligned sizes in
 	 * drm_gem_object_init(), so we should never hit this unless
-- 
1.9.1



More information about the dri-devel mailing list