Skip to content

Commit

Permalink
drm/i915: fix size_t greater or equal to zero comparison
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Colin Ian King authored and Rodrigo Vivi committed Dec 8, 2020
1 parent 0fe8bf4 commit 88c52d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gt/shmem_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void *shmem_pin_map(struct file *file)
mapping_set_unevictable(file->f_mapping);
return vaddr;
err_page:
while (--i >= 0)
while (i--)
put_page(pages[i]);
kvfree(pages);
return NULL;
Expand Down

0 comments on commit 88c52d8

Please sign in to comment.