From patchwork Tue Oct 25 17:34:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13019593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92BEEC38A2D for ; Tue, 25 Oct 2022 17:34:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE44A8E0002; Tue, 25 Oct 2022 13:34:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D93DB8E0001; Tue, 25 Oct 2022 13:34:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA9BF8E0002; Tue, 25 Oct 2022 13:34:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BFE9C8E0001 for ; Tue, 25 Oct 2022 13:34:48 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8C3EC1208F3 for ; Tue, 25 Oct 2022 17:34:48 +0000 (UTC) X-FDA: 80060171856.14.5E3322F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf05.hostedemail.com (Postfix) with ESMTP id E4BD1100003 for ; Tue, 25 Oct 2022 17:34:47 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DE6F8B81DAC; Tue, 25 Oct 2022 17:34:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A339C433D6; Tue, 25 Oct 2022 17:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666719284; bh=LmmlmDI/9NPsq0QGCvtmuqw5lnkthpFZOpXXgGIwnck=; h=From:To:Cc:Subject:Date:From; b=I3r1NmzfeNK3f9OJUJmeldgLvABnio6QcckHU/bm2RIjlbTKtrObTxxPL4/O7Mp3w ZRuKxjgS3Kuc+MgOhoPNvRh5w3mr67uEiZffVCQV9yS+PcJGZcwNdUaZZ1LqqD5O7V RNEGsknJIdTuq+k8MYu8JhgnPB95gdZHbMlSFIQde9DokxcmVy3Eu2DaSsStb3wCyM 0yiAw6ia96ErCi0S277hG50E8lUYTPo8ELvd7JpuCZUVgGRCMpdo8J0gij3vYhEjeB XGDj1UQ6uOLkJNoCTsDoP/Mbv+smHZ3kFUprf+gYSrZyezDP1sOr+E5xETFNS4jIZW HGua5UzcUHOJg== From: Nathan Chancellor To: Andrew Morton Cc: Gautam Menghani , Nick Desaulniers , Tom Rix , linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor , kernel test robot Subject: [PATCH] mm/khugepaged: Initialize index and nr in collapse_file() Date: Tue, 25 Oct 2022 10:34:07 -0700 Message-Id: <20221025173407.3423241-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666719288; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=+mHtiNXReAvMVXCIfRWKShF9VKoIMvT9jGDz5sHO4OI=; b=Mns5W6tlEqI0LNmuUZ0NeDd5oV9yh0p9OdvJ+iZHgQd7AsSSS/TNC8NYzMvUKuquaJdq8O sauldDuRYZNbgttSKdOgdmNOczeKBQt9UCk4NXVEBtNa4DTjOc0NbLvclSg0vCHEQEgvuT 07WExG4avvrRbXQ7/tSfYKTsZ/t/n6A= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=I3r1Nmzf; spf=pass (imf05.hostedemail.com: domain of nathan@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666719288; a=rsa-sha256; cv=none; b=Lb33chks5uKHrgYvRLKPcqWxouuu9NBsgeJufyA0H9jNbWGwo8veRKxBdCNhnfa/AU2nQJ UuPXGggs48EeY7wfufHTL9qM1QZxE2EFBaS3DQQxl/zA3tHVIl1g951DGX5u9EUmC88tyu q0btJm0MzWnMAGwJ1Oi78djo8WEhFqo= Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=I3r1Nmzf; spf=pass (imf05.hostedemail.com: domain of nathan@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: 7e4crdugwfh8ta6cxsbq9ci4gkift7wr X-Rspamd-Queue-Id: E4BD1100003 X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1666719287-230187 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Clang warns (trimmed for brevity): mm/khugepaged.c:1729:7: warning: variable 'index' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] mm/khugepaged.c:1716:6: warning: variable 'index' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] mm/khugepaged.c:1729:7: warning: variable 'nr' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] mm/khugepaged.c:1716:6: warning: variable 'nr' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] There are two goto statements that will use index and nr before they have been properly initialized. Zero initialize them so that they can be safely used by the tracepoint at the end of the function. Fixes: eae5270d3322 ("mm/khugepaged: add tracepoint to collapse_file()") Link: https://github.com/ClangBuiltLinux/linux/issues/1749 Reported-by: kernel test robot Signed-off-by: Nathan Chancellor Reviewed-by: Zach O'Keefe --- mm/khugepaged.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) base-commit: ec24a700584c4df869282bcd92b6d88329afe395 diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 977c0ff82c46..789db2f3fc06 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1702,12 +1702,12 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, { struct address_space *mapping = file->f_mapping; struct page *hpage; - pgoff_t index, end = start + HPAGE_PMD_NR; + pgoff_t index = 0, end = start + HPAGE_PMD_NR; LIST_HEAD(pagelist); XA_STATE_ORDER(xas, &mapping->i_pages, start, HPAGE_PMD_ORDER); int nr_none = 0, result = SCAN_SUCCEED; bool is_shmem = shmem_file(file); - int nr; + int nr = 0; VM_BUG_ON(!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && !is_shmem); VM_BUG_ON(start & (HPAGE_PMD_NR - 1));