]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.34/mm-sparse-fix-a-bad-comparison.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / mm-sparse-fix-a-bad-comparison.patch
1 From f288a532a6e95aa11f17245ffad35e2e0e23238d Mon Sep 17 00:00:00 2001
2 From: Qian Cai <cai@lca.pw>
3 Date: Tue, 5 Mar 2019 15:50:11 -0800
4 Subject: mm/sparse: fix a bad comparison
5
6 [ Upstream commit d778015ac95bc036af73342c878ab19250e01fe1 ]
7
8 next_present_section_nr() could only return an unsigned number -1, so
9 just check it specifically where compilers will convert -1 to unsigned
10 if needed.
11
12 mm/sparse.c: In function 'sparse_init_nid':
13 mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
14 ((section_nr >= 0) && \
15 ^~
16 mm/sparse.c:478:2: note: in expansion of macro
17 'for_each_present_section_nr'
18 for_each_present_section_nr(pnum_begin, pnum) {
19 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
20 mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
21 ((section_nr >= 0) && \
22 ^~
23 mm/sparse.c:497:2: note: in expansion of macro
24 'for_each_present_section_nr'
25 for_each_present_section_nr(pnum_begin, pnum) {
26 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
27 mm/sparse.c: In function 'sparse_init':
28 mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
29 ((section_nr >= 0) && \
30 ^~
31 mm/sparse.c:520:2: note: in expansion of macro
32 'for_each_present_section_nr'
33 for_each_present_section_nr(pnum_begin + 1, pnum_end) {
34 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
35
36 Link: http://lkml.kernel.org/r/20190228181839.86504-1-cai@lca.pw
37 Fixes: c4e1be9ec113 ("mm, sparsemem: break out of loops early")
38 Signed-off-by: Qian Cai <cai@lca.pw>
39 Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
40 Cc: Dave Hansen <dave.hansen@linux.intel.com>
41 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
42 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
43 Signed-off-by: Sasha Levin <sashal@kernel.org>
44 ---
45 mm/sparse.c | 2 +-
46 1 file changed, 1 insertion(+), 1 deletion(-)
47
48 diff --git a/mm/sparse.c b/mm/sparse.c
49 index 10b07eea9a6e..45950a074bdb 100644
50 --- a/mm/sparse.c
51 +++ b/mm/sparse.c
52 @@ -196,7 +196,7 @@ static inline int next_present_section_nr(int section_nr)
53 }
54 #define for_each_present_section_nr(start, section_nr) \
55 for (section_nr = next_present_section_nr(start-1); \
56 - ((section_nr >= 0) && \
57 + ((section_nr != -1) && \
58 (section_nr <= __highest_present_section_nr)); \
59 section_nr = next_present_section_nr(section_nr))
60
61 --
62 2.19.1
63