You need to sign in or sign up before continuing.
提交 b393aeee 编写于 作者: Q Qian Cai 提交者: Xie XiuQi

mm/sparse: fix a bad comparison

mainline inclusion
from mainline-5.0
commit d778015a
category: bugfix
bugzilla: 11612
CVE: NA

------------------------------------------------

next_present_section_nr() could only return an unsigned number -1, so just
check it specifically where compilers will convert -1 to unsigned if
needed.

mm/sparse.c: In function 'sparse_init_nid':
mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is
always true [-Wtype-limits]
       ((section_nr >= 0) &&    \
                    ^~
mm/sparse.c:478:2: note: in expansion of macro
'for_each_present_section_nr'
  for_each_present_section_nr(pnum_begin, pnum) {
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is
always true [-Wtype-limits]
       ((section_nr >= 0) &&    \
                    ^~
mm/sparse.c:497:2: note: in expansion of macro
'for_each_present_section_nr'
  for_each_present_section_nr(pnum_begin, pnum) {
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/sparse.c: In function 'sparse_init':
mm/sparse.c:200:20: warning: comparison of unsigned expression >= 0 is
always true [-Wtype-limits]
       ((section_nr >= 0) &&    \
                    ^~
mm/sparse.c:520:2: note: in expansion of macro
'for_each_present_section_nr'
  for_each_present_section_nr(pnum_begin + 1, pnum_end) {
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Link: http://lkml.kernel.org/r/20190228181839.86504-1-cai@lca.pw
Fixes: c4e1be9e ("mm, sparsemem: break out of loops early")
Signed-off-by: NQian Cai <cai@lca.pw>
Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Nzhong jiang <zhongjiang@huawei.com>
Reviewed-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f631fcd0
...@@ -196,7 +196,7 @@ static inline int next_present_section_nr(int section_nr) ...@@ -196,7 +196,7 @@ static inline int next_present_section_nr(int section_nr)
} }
#define for_each_present_section_nr(start, section_nr) \ #define for_each_present_section_nr(start, section_nr) \
for (section_nr = next_present_section_nr(start-1); \ for (section_nr = next_present_section_nr(start-1); \
((section_nr >= 0) && \ ((section_nr != -1) && \
(section_nr <= __highest_present_section_nr)); \ (section_nr <= __highest_present_section_nr)); \
section_nr = next_present_section_nr(section_nr)) section_nr = next_present_section_nr(section_nr))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册