From patchwork Fri Dec 15 12:51:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 122084 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp429311qgn; Fri, 15 Dec 2017 04:53:06 -0800 (PST) X-Google-Smtp-Source: ACJfBostXVH0ZtGqiJzNYAWwcJ8lM/93cMYuH6nRxOMSxnHiarlkPRO2pw3WNFCiRwrKrny8SWpN X-Received: by 10.99.127.88 with SMTP id p24mr11785204pgn.98.1513342386340; Fri, 15 Dec 2017 04:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513342386; cv=none; d=google.com; s=arc-20160816; b=ZeggjaAjEZJQuYykGLYJOXQvGmktHt6GNzkw87Ak7q9tDfmwevnfXmIBSSO1dKZFdo 8uRrlKi3kg84LLuGjre0h6biPFrj/cngKAmRg7Nrhe0ltBLamlP4Evto67xF3Q/8P+Pv GjAgfQaaDAnaE+LtJaq+ByAlAX63SGH/Sw9kpVdYanw1EHpDYYpqcctAsiOHTG+w05cO tTb/YVwVRvJ/NJS0ORQx+Gtqly61jsRymS7aa7C3U/CcLnNJjQPORryqeKromJnkkDTC w3f4oP1EPWWNWi0upi4W+j9RUMwUODXXSjCFKArl6EmFTJjWtdTws5P7pRx3XH+OoHiR Ps6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=N2XDWVF5Xdf/NaG4lGFt48uKXkV39HBhgG0//2qECvo=; b=Qf6Mn9bGUP338doK3DRbCkqvq9mX8ATkCIKxTPufMhO742SxDYrTzdwmeGJWCm8FqW CobSIUEPGratktUmZVwZMg99Aza5kFy/NkUmCDqkP+J1ofKOT8FUpHozTx8JA9fPn6mY oE70fA9a/j7bAWaYnVCUOeIAdue/lQgJz33YiRfeph0ha7gCZAIcw53AErzaNr4n2WDP UGZQIZf76efAmg2ctsEFtFhfhC0rNgFVuN93iIif9E4/8ribdoxmYLu5DyHPUrk5n5BD lXOSmi0/aykPEmtpU4YnFOQqlUGrhkHhUkg579HNDJoH0TOjWasxsOboInpTvj+hNEeq b/+w== 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 f13si4449038pgp.297.2017.12.15.04.53.06; Fri, 15 Dec 2017 04:53:06 -0800 (PST) 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 S1756125AbdLOMxD (ORCPT + 20 others); Fri, 15 Dec 2017 07:53:03 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:53650 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755555AbdLOMw4 (ORCPT ); Fri, 15 Dec 2017 07:52:56 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0M7nzI-1fC2MR1g4u-00vQTY; Fri, 15 Dec 2017 13:51:35 +0100 From: Arnd Bergmann To: Andrew Morton , Michal Hocko , "Kirill A. Shutemov" Cc: Arnd Bergmann , Stephen Rothwell , Vlastimil Babka , David Rientjes , Ingo Molnar , Yang Shi , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: thp: avoid uninitialized variable use Date: Fri, 15 Dec 2017 13:51:04 +0100 Message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c9qlDrzojmND1 5QjEywMOUt8m8Q0f56eDCmhO+8IOHSRKJgqrXA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the down_read_trylock() fails, 'vma' has not been initialized yet, which gcc now warns about: mm/khugepaged.c: In function 'khugepaged': mm/khugepaged.c:1659:25: error: 'vma' may be used uninitialized in this function [-Werror=maybe-uninitialized] Presumable we are not supposed to call find_vma() without the mmap_sem either, so setting it to NULL for this case seems appropriate. Fixes: 0951b59acf3a ("mm: thp: use down_read_trylock() in khugepaged to avoid long block") Signed-off-by: Arnd Bergmann --- I'm not completely sure this patch is sufficient, it gets rid of the warning, but it would be good to have the code reviewed better to see if other problems remain that result from down_read_trylock() patch. --- mm/khugepaged.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.9.0 Acked-by: Michal Hocko diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 521b908f9600..b7e2268dfc9a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1677,11 +1677,10 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, * Don't wait for semaphore (to avoid long wait times). Just move to * the next mm on the list. */ + vma = NULL; if (unlikely(!down_read_trylock(&mm->mmap_sem))) goto breakouterloop_mmap_sem; - if (unlikely(khugepaged_test_exit(mm))) - vma = NULL; - else + if (likely(!khugepaged_test_exit(mm))) vma = find_vma(mm, khugepaged_scan.address); progress++;