summaryrefslogtreecommitdiffstats
path: root/lib/nodemask.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2022-05-18 13:52:23 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-14 18:36:24 +0200
commitf293dfc18404a35679c62295ebf3d0f2d788f379 (patch)
treed82eb7d9cddcda8c78c0c1d5897a599a24cc5392 /lib/nodemask.c
parentb2d359f095883d10b33e74a4a404363d2312830d (diff)
downloadlinux-stable-f293dfc18404a35679c62295ebf3d0f2d788f379.tar.gz
linux-stable-f293dfc18404a35679c62295ebf3d0f2d788f379.tar.bz2
linux-stable-f293dfc18404a35679c62295ebf3d0f2d788f379.zip
nodemask: Fix return values to be unsigned
[ Upstream commit 0dfe54071d7c828a02917b595456bfde1afdddc9 ] The nodemask routines had mixed return values that provided potentially signed return values that could never happen. This was leading to the compiler getting confusing about the range of possible return values (it was thinking things could be negative where they could not be). Fix all the nodemask routines that should be returning unsigned (or bool) values. Silences: mm/swapfile.c: In function ‘setup_swap_info’: mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds of ‘struct plist_node[]’ [-Werror=array-bounds] 2291 | p->avail_lists[i].prio = 1; | ~~~~~~~~~~~~~~^~~ In file included from mm/swapfile.c:16: ./include/linux/swap.h:292:27: note: while referencing ‘avail_lists’ 292 | struct plist_node avail_lists[]; /* | ^~~~~~~~~~~ Reported-by: Christophe de Dinechin <dinechin@redhat.com> Link: https://lore.kernel.org/lkml/20220414150855.2407137-3-dinechin@redhat.com/ Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Yury Norov <yury.norov@gmail.com> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Yury Norov <yury.norov@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib/nodemask.c')
-rw-r--r--lib/nodemask.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/nodemask.c b/lib/nodemask.c
index 3aa454c54c0d..e22647f5181b 100644
--- a/lib/nodemask.c
+++ b/lib/nodemask.c
@@ -3,9 +3,9 @@
#include <linux/module.h>
#include <linux/random.h>
-int __next_node_in(int node, const nodemask_t *srcp)
+unsigned int __next_node_in(int node, const nodemask_t *srcp)
{
- int ret = __next_node(node, srcp);
+ unsigned int ret = __next_node(node, srcp);
if (ret == MAX_NUMNODES)
ret = __first_node(srcp);