mm/gup_benchmark: fix unsigned comparison to zero in __gup_benchmark_ioctl
authorYueHaibing <[email protected]>
Fri, 5 Oct 2018 22:51:44 +0000 (15:51 -0700)
committerGreg Kroah-Hartman <[email protected]>
Fri, 5 Oct 2018 23:32:04 +0000 (16:32 -0700)
get_user_pages_fast() will return negative value if no pages were pinned,
then be converted to a unsigned, which is compared to zero, giving the
wrong result.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 09e35a4a1ca8 ("mm/gup_benchmark: handle gup failures")
Signed-off-by: YueHaibing <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
mm/gup_benchmark.c

index 6a473709e9b6b953393ea12215a38c9e47c9f849..7405c9d89d65134c003a2d3984e1a993fd9c9907 100644 (file)
@@ -19,7 +19,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
                struct gup_benchmark *gup)
 {
        ktime_t start_time, end_time;
-       unsigned long i, nr, nr_pages, addr, next;
+       unsigned long i, nr_pages, addr, next;
+       int nr;
        struct page **pages;
 
        nr_pages = gup->size / PAGE_SIZE;