diff mbox series

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

Message ID 20240825174128.474100-1-sui.jingfeng@linux.dev (mailing list archive)
State New, archived
Headers show
Series drm/etnaviv: Use unsigned type to count the number of userspace pages | expand

Commit Message

Sui Jingfeng Aug. 25, 2024, 5:41 p.m. UTC
The unpin_user_pages() function takes an unsigned long argument to store
length of the number of user space pages, and struct drm_gem_object::size
is a size_t type. The number of pages can not be negative, hence, use an
unsigned variable to store the number of pages.

Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Gmeiner Aug. 26, 2024, 2:23 p.m. UTC | #1
>
> The unpin_user_pages() function takes an unsigned long argument to store
> length of the number of user space pages, and struct drm_gem_object::size
> is a size_t type. The number of pages can not be negative, hence, use an
> unsigned variable to store the number of pages.
>
> Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>

Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index ce9c9233c4a6..fa0d193cec26 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -695,7 +695,7 @@ static void etnaviv_gem_userptr_release(struct etnaviv_gem_object *etnaviv_obj)
>                 kfree(etnaviv_obj->sgt);
>         }
>         if (etnaviv_obj->pages) {
> -               int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
> +               unsigned int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
>
>                 unpin_user_pages(etnaviv_obj->pages, npages);
>                 kvfree(etnaviv_obj->pages);
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index ce9c9233c4a6..fa0d193cec26 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -695,7 +695,7 @@  static void etnaviv_gem_userptr_release(struct etnaviv_gem_object *etnaviv_obj)
 		kfree(etnaviv_obj->sgt);
 	}
 	if (etnaviv_obj->pages) {
-		int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
+		unsigned int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
 
 		unpin_user_pages(etnaviv_obj->pages, npages);
 		kvfree(etnaviv_obj->pages);