Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp995224yba; Thu, 4 Apr 2019 02:01:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeHYdz9H6egsLW0WcuX9EaBDwmnxPVeZMU47+cGU66XXkQn7+3w8GBDvo0mBfN+HzD0oaw X-Received: by 2002:a63:c118:: with SMTP id w24mr4451445pgf.67.1554368487260; Thu, 04 Apr 2019 02:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368487; cv=none; d=google.com; s=arc-20160816; b=ITu4tG5AIl91mYFgdRA6yavIOEgRsP4Hcw/e64ozO6MzWSqRkT+UOjGkE9MMtfns0L j/qFAjBHUj0DoEqFRNxlBi0PFgXxEYn+POwCVsdCX6vMiDx0U4e/DuDkoJKqEmtjo7MX X/p8S6H3HacN5eIl92FQ0+y5TJkRdjvw1iNhJQFiuyb9suKENkvbCyN6dfzJmIQbr2kq 5pGjyIyQFin6UNfwca+rpIf5R4L/n94nSL+lxyALl/EerRRExZI7UK7wO4V196DVdo8A BLhfDsb7nqYNwGBBfmWY/3mBEiU1CNfK3hXjoTI2iENd/xqUyVTK8ZwnXYUq8E2zMRaS hY1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r1HsyzPcRpP0WCUzMWXeWvb1K1JrrURyTG3VmV/UUUY=; b=x2eZPbde2JijFZxTxkrb7TP8ZwYEq0eM+W+bpDY7IfqMpXk/IxZ7kfAVd6jFgUDRfW J50G0n70oshzgLMaZjOgpM8+cxp6B7jb/mQl1bZ4F62eENDiFMRbjdlQ9Qb28zJMp28w f/LITcUSBiVTaA/bS81AkaNUVDaJWpfm+ozM5F+bdnajDoGkSun8rssZTVucJvqJwMFv s4URq4Kk55m0bbKsimjNqcbejJlo0nUfAdEW2Qg+EyaZFf9qmVEnMbvj0lVDSNFm3XOh 28ObfkQ/NJLfTEFCdc5DQ/lvKNzKuZ7Ai9FJaoA8WXttJpoG++HBT0g8+h15ibJCgW49 CXNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xSjSXiT6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si15749702pfn.135.2019.04.04.02.01.11; Thu, 04 Apr 2019 02:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xSjSXiT6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731275AbfDDJAj (ORCPT + 99 others); Thu, 4 Apr 2019 05:00:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:37368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731268AbfDDJAf (ORCPT ); Thu, 4 Apr 2019 05:00:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AA2C2186A; Thu, 4 Apr 2019 09:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368434; bh=d79nm7yo6gb7XyAYspQJXBCB5KtCIjbFxVxxh9tL7Nk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xSjSXiT6P5f9opxdqIX2XlpeoCFDWQCV0hYRYAo1eE30I4CJkjCn0gCTvhYLiVwYz CJbfJjxkM+uO7NoeeR12DDuxiSdMpR408YLfz6W3lxWZpGG3esvFnaKlf05AaRlFRH 8ifuXtxHyC5ea25HYa5ZHqcS+O+LloEP3ViF3tHo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qian Cai , Andrew Morton , Dave Hansen , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 023/187] mm/sparse: fix a bad comparison Date: Thu, 4 Apr 2019 10:46:00 +0200 Message-Id: <20190404084604.168765554@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d778015ac95bc036af73342c878ab19250e01fe1 ] 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: c4e1be9ec113 ("mm, sparsemem: break out of loops early") Signed-off-by: Qian Cai Reviewed-by: Andrew Morton Cc: Dave Hansen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/sparse.c b/mm/sparse.c index 10b07eea9a6e..45950a074bdb 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -196,7 +196,7 @@ static inline int next_present_section_nr(int section_nr) } #define for_each_present_section_nr(start, section_nr) \ for (section_nr = next_present_section_nr(start-1); \ - ((section_nr >= 0) && \ + ((section_nr != -1) && \ (section_nr <= __highest_present_section_nr)); \ section_nr = next_present_section_nr(section_nr)) -- 2.19.1