lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1462973126-1183468-1-git-send-email-arnd@arndb.de>
Date:	Wed, 11 May 2016 15:24:44 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Michal Hocko <mhocko@...e.com>
Cc:	Arnd Bergmann <arnd@...db.de>,
	Mel Gorman <mgorman@...hsingularity.net>,
	Vlastimil Babka <vbabka@...e.cz>,
	David Rientjes <rientjes@...gle.com>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	Taku Izumi <izumi.taku@...fujitsu.com>,
	Johannes Weiner <hannes@...xchg.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] mm, compaction: avoid uninitialized variable use

A recent rework of the compaction code introduced a warning about
an uninitialized variable when CONFIG_COMPACTION is disabled and
__alloc_pages_direct_compact() does not set its 'compact_result'
output argument:

mm/page_alloc.c: In function '__alloc_pages_nodemask':
mm/page_alloc.c:3651:6: error: 'compact_result' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This adds another check for CONFIG_COMPACTION to ensure we never
evaluate the uninitialized variable in this configuration, which
is probably the simplest way to avoid the warning.

A more elaborate rework might make this more readable.

Signed-off-by: Arnd Bergmann <arnd@...db.de>
Fixes: 13cff7b81275 ("mm, compaction: simplify __alloc_pages_direct_compact feedback interface")
---
 mm/page_alloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 477d9382f70d..bedadc686a22 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3640,7 +3640,8 @@ retry:
 		goto got_pg;
 
 	/* Checks for THP-specific high-order allocations */
-	if (is_thp_gfp_mask(gfp_mask)) {
+	if (IS_ENABLED(CONFIG_COMPACTION) &&
+		is_thp_gfp_mask(gfp_mask)) {
 		/*
 		 * If compaction is deferred for high-order allocations, it is
 		 * because sync compaction recently failed. If this is the case
-- 
2.7.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ