* [PATCH] lib/group_cpus: Fix unsigned expression compared with zero
@ 2024-01-12 2:02 Jiapeng Chong
2024-01-12 2:19 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-01-12 2:02 UTC (permalink / raw)
To: tglx; +Cc: akpm, linux-kernel, Jiapeng Chong, Abaci Robot
The nr_present and nr_others is defined as unsigned int type,
if(nr_present < 0) and if(nr_others < 0 )is invalid. At the same time, the
return value of function __group_cpus_evenly also of type int. so modified
the types of nr_present and nr_others to int.
lib/group_cpus.c:380 group_cpus_evenly() warn: unsigned 'nr_present' is never less than zero.
lib/group_cpus.c:396 group_cpus_evenly() warn: unsigned 'nr_others' is never less than zero.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7890
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
lib/group_cpus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/group_cpus.c b/lib/group_cpus.c
index 3a0db0f51f09..08e31f2f053f 100644
--- a/lib/group_cpus.c
+++ b/lib/group_cpus.c
@@ -354,7 +354,8 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps)
cpumask_var_t *node_to_cpumask __free(free_node_to_cpumask) = alloc_node_to_cpumask();
struct cpumask *masks __free(kfree) = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
cpumask_var_t npresmsk __free(free_cpumask_var);
- unsigned int curgrp, nr_present, nr_others;
+ unsigned int curgrp;
+ int nr_present, nr_others;
if (!masks || !node_to_cpumask || !alloc_cpumask_var(&npresmsk, GFP_KERNEL))
return NULL;
--
2.20.1.7.g153144c
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] lib/group_cpus: Fix unsigned expression compared with zero
2024-01-12 2:02 [PATCH] lib/group_cpus: Fix unsigned expression compared with zero Jiapeng Chong
@ 2024-01-12 2:19 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2024-01-12 2:19 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: tglx, linux-kernel, Abaci Robot
On Fri, 12 Jan 2024 10:02:50 +0800 Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:
> The nr_present and nr_others is defined as unsigned int type,
> if(nr_present < 0) and if(nr_others < 0 )is invalid. At the same time, the
> return value of function __group_cpus_evenly also of type int. so modified
> the types of nr_present and nr_others to int.
>
> lib/group_cpus.c:380 group_cpus_evenly() warn: unsigned 'nr_present' is never less than zero.
> lib/group_cpus.c:396 group_cpus_evenly() warn: unsigned 'nr_others' is never less than zero.
>
> ...
>
> --- a/lib/group_cpus.c
> +++ b/lib/group_cpus.c
> @@ -354,7 +354,8 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps)
> cpumask_var_t *node_to_cpumask __free(free_node_to_cpumask) = alloc_node_to_cpumask();
> struct cpumask *masks __free(kfree) = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
> cpumask_var_t npresmsk __free(free_cpumask_var);
> - unsigned int curgrp, nr_present, nr_others;
> + unsigned int curgrp;
> + int nr_present, nr_others;
>
> if (!masks || !node_to_cpumask || !alloc_cpumask_var(&npresmsk, GFP_KERNEL))
> return NULL;
Thanks.
Current mm.git (pushed 3 hours ago) has
int curgrp, nr_present, nr_others;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-12 2:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12 2:02 [PATCH] lib/group_cpus: Fix unsigned expression compared with zero Jiapeng Chong
2024-01-12 2:19 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®