Skip to contentSkip to conversation

drm/etnaviv: Use unsigned type to count the number of pages

PATCH In review Sui Jingfeng 2 participants 2 messages Aug 25, 2024 – Aug 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/etnaviv: Use unsigned type to count the number of pages

The drm_prime_pages_to_sg() function takes unsigned int argument to store length of the page vector, and the type of struct drm_gem_object::size is a size_t. The size of the object in CPU pages can not be negative, hence, use unsigned variable to store the number of pages, instead of the signed type.

---
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +1 -1
index 3524b5811682..6b98200068e4 100644
@@ -17,7 +17,7 @@ static struct lock_class_key etnaviv_prime_lock_class;
 struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
 	struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
-	int npages = obj->size >> PAGE_SHIFT;
+	unsigned int npages = obj->size >> PAGE_SHIFT;
 
 	if (WARN_ON(!etnaviv_obj->pages))  /* should have already pinned! */
 		return ERR_PTR(-EINVAL);
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines

The drm_prime_pages_to_sg() function takes unsigned int argument to store length of the page vector, and the type of struct drm_gem_object::size is a size_t. The size of the object in CPU pages can not be negative, hence, use unsigned variable to store the number of pages, instead of the signed type.

Quoted 20 lines
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +1 -2
index 3524b5811682..6b98200068e4 100644
@@ -17,7 +17,7 @@ static struct lock_class_key etnaviv_prime_lock_class;
 struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
        struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
-       int npages = obj->size >> PAGE_SHIFT;
+       unsigned int npages = obj->size >> PAGE_SHIFT;
 
        if (WARN_ON(!etnaviv_obj->pages))  /* should have already pinned! */
                return ERR_PTR(-EINVAL);
--

2.34.1

Signature · 5 lines
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy