Message ID | 20240112020250.48087-1-jiapeng.chong@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-24223-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1852715dyi; Thu, 11 Jan 2024 18:08:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzWO7IJ/hE+hw2nJfostpg2z+sZMpK8xq2RhC5+xS0+YKK2SgOrcYp5bFS/BW0AUF6KUSW X-Received: by 2002:a17:90a:5d11:b0:28d:950f:f1ca with SMTP id s17-20020a17090a5d1100b0028d950ff1camr1156668pji.2.1705025317116; Thu, 11 Jan 2024 18:08:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705025317; cv=none; d=google.com; s=arc-20160816; b=vk1bkxS92j30aovL1kZcJgnzTFadtaJkybKEkvMaO/wVuxCgHxc17p9r2k/Uk5eaPH WXza402PCtjF0yVYqnbh/7/Eko2hvIB02M/MPSLXxh6LOV6OPx33vV6k+JtdnnnkJUoA CzAA3vR1+ErsiQginkpMyKWdiP3gkyF9+sGP63Yk2pi7cr2CxWfA5pEZM0aC4igIOgZz Z+oM26AUz9YplidqHOYPt7F+TT77xUqEvxneLXiOoSjoXhrMfHx98ZlS4pI2dXolz2/S DxZTVb0JaRL6+ER5IfxOm0PJEzYaVAIDNaO6j/kPz1HTk020Djjio7VN9Gky5jOM+fuR gTBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Av/eq/nWgYze9DHw/whtba1h6eCvgLh2s3Om4RasXGw=; fh=/YeIsC882I45dlqGUcm20dvbkohg5JzeYrfHTaftsWM=; b=ZAIUtQFeZD/L+ZSmsHcxewq88YggnbVZOwa+80BnVkSSjqNekFo7yZ1RztWbTNCfgO Bq8ZZkkCtgXUVsurej75ycaaxONkpEnJvy3V+Ngt5EW7Mvp4qUA8upVnMoIVIhvph8Qk ribghOsSOiiTUSKUnWIW6hbDSThxjspX+rjuosXhCI+Al3gxIla88JiG6yYh7+Leen3H c1g2FSNqonn30WfyglX+Cg3JgcW58xBO/KGUKIDPGij1q6dyrBZzWCHIxV3jUD2F1Om0 8tnl5Tob6W77W/Y+gJuMnf4q3C+znN8hXh86qVqQD/MuWHfUODAMxycfM7iC4WBZpBRp BAyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24223-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24223-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ji13-20020a170903324d00b001d05450e410si2240285plb.208.2024.01.11.18.08.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 18:08:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24223-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24223-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24223-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DDE2D285E23 for <ouuuleilei@gmail.com>; Fri, 12 Jan 2024 02:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA51E17FE; Fri, 12 Jan 2024 02:08:24 +0000 (UTC) Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59E17ED7 for <linux-kernel@vger.kernel.org>; Fri, 12 Jan 2024 02:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0W-R94xv_1705024971; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0W-R94xv_1705024971) by smtp.aliyun-inc.com; Fri, 12 Jan 2024 10:03:00 +0800 From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> To: tglx@linutronix.de Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Jiapeng Chong <jiapeng.chong@linux.alibaba.com>, Abaci Robot <abaci@linux.alibaba.com> Subject: [PATCH] lib/group_cpus: Fix unsigned expression compared with zero Date: Fri, 12 Jan 2024 10:02:50 +0800 Message-Id: <20240112020250.48087-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787848626711102809 X-GMAIL-MSGID: 1787848626711102809 |
Series |
lib/group_cpus: Fix unsigned expression compared with zero
|
|
Commit Message
Jiapeng Chong
Jan. 12, 2024, 2:02 a.m. UTC
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(-)
Comments
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;
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;