mm/cma_debug.c: fix the break condition in cma_maxchunk_get()
authorYue Hu <huyue2@yulong.com>
Tue, 14 May 2019 00:16:37 +0000 (17:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 May 2019 16:47:45 +0000 (09:47 -0700)
If not find zero bit in find_next_zero_bit(), it will return the size
parameter passed in, so the start bit should be compared with bitmap_maxno
rather than cma->count.  Although getting maxchunk is working fine due to
zero value of order_per_bit currently, the operation will be stuck if
order_per_bit is set as non-zero.

Link: http://lkml.kernel.org/r/20190319092734.276-1-zbestahu@gmail.com
Signed-off-by: Yue Hu <huyue2@yulong.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Joe Perches <joe@perches.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Dmitry Safonov <d.safonov@partner.samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/cma_debug.c

index 8d7b2fd5222599a4045608e0b9b499eb91deb51f..a7dd9e8e10d5da4c914e9eebff27e42b3b0e9652 100644 (file)
@@ -56,7 +56,7 @@ static int cma_maxchunk_get(void *data, u64 *val)
        mutex_lock(&cma->lock);
        for (;;) {
                start = find_next_zero_bit(cma->bitmap, bitmap_maxno, end);
-               if (start >= cma->count)
+               if (start >= bitmap_maxno)
                        break;
                end = find_next_bit(cma->bitmap, bitmap_maxno, start);
                maxchunk = max(end - start, maxchunk);