Skip to content

Commit 88c52d8

Browse files
Colin Ian Kingrodrigovivi
authored andcommitted
drm/i915: fix size_t greater or equal to zero comparison
Currently the check that the unsigned size_t variable i is >= 0 is always true because the unsigned variable will never be negative, causing the loop to run forever. Fix this by changing the pre-decrement check to a zero check on i followed by a decrement of i. Addresses-Coverity: ("Unsigned compared against 0") Fixes: bfed670 ("drm/i915: use vmap in shmem_pin_map") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20201002170354.94627-1-colin.king@canonical.com (cherry picked from commit e70956a) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 0fe8bf4 commit 88c52d8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/gpu/drm/i915/gt/shmem_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void *shmem_pin_map(struct file *file)
7373
mapping_set_unevictable(file->f_mapping);
7474
return vaddr;
7575
err_page:
76-
while (--i >= 0)
76+
while (i--)
7777
put_page(pages[i]);
7878
kvfree(pages);
7979
return NULL;

0 commit comments

Comments
 (0)