From patchwork Tue Jun 18 09:26:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 167120 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3969206ilk; Tue, 18 Jun 2019 02:28:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwmS0YdRrgEoyR+JsE9sMmv6JPo4FWF+E7xqm5a0lrJMdltp09t5leqNbiG50MqjYThX// X-Received: by 2002:a17:902:25ab:: with SMTP id y40mr57029539pla.268.1560850089125; Tue, 18 Jun 2019 02:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560850089; cv=none; d=google.com; s=arc-20160816; b=EthcIuDS0rKsu+xO7Qge5CRduJsm7A9ZPyKEAVc5/Q/X6J7gDKRrGehzEBNnNpegE3 M3o5zmxMRq0n69f2cKeXDyMarJT1ANIQFoYZ0TJ/43MakQTmox0Q0vGFzLBEfiz05IQQ DJEy21fCljYS/Z8cmNdWjMGPU7cE+H2ow7f0cWUdKqQ27jxmwnA2G2BqG7QwectCPJw5 orI6rNwlsNX3pR7tj7idEOAPGtwIAtTuHQgQ2leACaf4bc/+T83qnmz05Z4/j6+S7y6I 7UsH/b9HwZHETWZFxWNo5c/Sjzh1PVFk9g0JMDwnBzvpLMftn0uDaxVEkeZ5ZhHr3JzO jH5A== 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 :message-id:date:subject:cc:to:from; bh=wLTPJBXZmunStbE+y7KuITwpU+6UYwCLQzOFUh6PBJc=; b=pfUpNJdeQ/QFE9Ln8RC8/y+/2ndqKg4AL4Xt1nnFCrcMpRTjpXZ93+W/EIlL/pGhCD 2QeylUmqoYIskbu7jPFJZqZmm3zeDWMOmsSJ13Lwf76rTvMwIyERnjkYu1ZMcwPMXIhB wYafNKIYk8HU0nvXDKnY1sAp6ZFYHbehb6dr7NuvNBmH/TVXIR8JFQYiFY2WnAsCuiF1 Qgaf0H4vyhxJ5XxkgmU/5AhaC6I6d9n9tGPAHdCBd+WI3vQx9VOpo8TW187id0KA+TaS EQPfOsMmDJT0M0VT8CxeeQBS/2qd77mUC+qj8RZWx8fG6OTXPkLQbrKLkc0xeo8Rq3XR hBzA== ARC-Authentication-Results: i=1; mx.google.com; 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 l102si1808998pje.78.2019.06.18.02.28.08; Tue, 18 Jun 2019 02:28:09 -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; 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 S1729301AbfFRJ2G (ORCPT + 29 others); Tue, 18 Jun 2019 05:28:06 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:47479 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729113AbfFRJ2G (ORCPT ); Tue, 18 Jun 2019 05:28:06 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPA (Nemesis) id 1MPGmZ-1hyPk2355h-00PcPO; Tue, 18 Jun 2019 11:27:03 +0200 From: Arnd Bergmann To: Roman Penyaev , Uladzislau Rezki , Andrew Morton Cc: linux-mm@kvack.org, Arnd Bergmann , Roman Gushchin , Michal Hocko , Matthew Wilcox , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo , Linus Torvalds , Rick Edgecombe , Andrey Ryabinin , Mike Rapoport , linux-kernel@vger.kernel.org Subject: [PATCH] mm/vmalloc: avoid bogus -Wmaybe-uninitialized warning Date: Tue, 18 Jun 2019 11:26:28 +0200 Message-Id: <20190618092650.2943749-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:9NZTdj7yHA17SVjH2nsfAF6APnEovvSLZjPtTFenlB3oKrJaDJO stMbkNAyqRtMaQzlUFZq5gMFl9e5fUH+jLGvVh/1GxRU2mwjU22tOO198CJxWdQkTkKa3Gf n2Ur2ohACWrOuIv4HOFefTF6AimVTY39XDgbKSv4ASeO4vIQjq/vqMliduz7kXeQ4KpTxPc FDvntWSMeWiJ/cL7slu9g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:jKozyIbKSIg=:4cBighBCTsEi6eFn3Hf1bU lTcJF857e6/rZJtR3ljY7QsUglzRcHnQctUHBRPg4y7AiM72cT4uMwRE73kKbK9g5TfwHQY8E VQilimjiv/r9kBJAzUZsudyviQqowepJjhFdgOacpEfKiEyWRFRZzzEK6FZOtll9gkRkzOw5r 8xWT+IqMLi46wA1sStXC+tY/TlF8odu+MWInAbwPk8kRiuCZk4/LkbBrF90jUwXkC4+mH92Jo 2jRAdjtEO5vQzkNvDlvxnGwwAXDMuinixOGPoDemcwmEPEz22KMOurOO/MxO9QIohwC+wlT67 f4RVwVRt6BSqgFPXhop+vHSLMQCzafwkOiwhy0XGeUTympDL/b4MkJOAI98cA+pPZJ51IYdf+ T2X99HWuhxgfjNC6X955THzCzutkwalUcQlCMmjbCdUoQ7Ntx+VobHF7dP5pKP7mda2QWVLHr PMjQhKGJT36gCvyMPyfPMNihxXGlX4NBilG7RFYqQd6MrUb40xcMB7IXKzIF8iemdM4lu6gjk MDWpUYsKFl7TFnxdCaTrTUMQnbS6D2C95hR77lH2COVISmVvutl9mmRtrMlebExExKkZZLiSF GTLThNbIGCAfmNu+T308kS6mfMbrwQ/SzFGeU9WsWRbSUwA7vsylBi+XUT/uIXY8CvCU+exgF m7P/Nf1kStwR/esTk5NIlZy/BJeqFP35zmhqtflX9Mt1sq3qXynZjCZFasJkvEGZCg+qBIJWW Y6t8thZrqAtdN20hVu4ohWcIwAk59XoX4z5hSg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc gets confused in pcpu_get_vm_areas() because there are too many branches that affect whether 'lva' was initialized before it gets used: mm/vmalloc.c: In function 'pcpu_get_vm_areas': mm/vmalloc.c:991:4: error: 'lva' may be used uninitialized in this function [-Werror=maybe-uninitialized] insert_vmap_area_augment(lva, &va->rb_node, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &free_vmap_area_root, &free_vmap_area_list); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/vmalloc.c:916:20: note: 'lva' was declared here struct vmap_area *lva; ^~~ Add an intialization to NULL, and check whether this has changed before the first use. Fixes: 68ad4a330433 ("mm/vmalloc.c: keep track of free blocks for vmap allocation") Signed-off-by: Arnd Bergmann --- mm/vmalloc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.20.0 Reviewed-by: Uladzislau Rezki (Sony) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a9213fc3802d..42a6f795c3ee 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -913,7 +913,12 @@ adjust_va_to_fit_type(struct vmap_area *va, unsigned long nva_start_addr, unsigned long size, enum fit_type type) { - struct vmap_area *lva; + /* + * GCC cannot always keep track of whether this variable + * was initialized across many branches, therefore set + * it NULL here to avoid a warning. + */ + struct vmap_area *lva = NULL; if (type == FL_FIT_TYPE) { /* @@ -987,7 +992,7 @@ adjust_va_to_fit_type(struct vmap_area *va, if (type != FL_FIT_TYPE) { augment_tree_propagate_from(va); - if (type == NE_FIT_TYPE) + if (lva) insert_vmap_area_augment(lva, &va->rb_node, &free_vmap_area_root, &free_vmap_area_list); }