Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8846810rwi; Tue, 25 Oct 2022 11:33:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TWspqQWRS+9HPLqtY2DLJ9OBpLRljLrT57yX6ob9Ej2eue/BSkbpJJVQbURluyqQG7eoA X-Received: by 2002:a05:6402:d0b:b0:458:a244:4e99 with SMTP id eb11-20020a0564020d0b00b00458a2444e99mr37187798edb.46.1666722830510; Tue, 25 Oct 2022 11:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666722830; cv=none; d=google.com; s=arc-20160816; b=z5FVD10r+OH2f0W0eM+eLXrttckeprZoor4dm2lrIRWxgAtuCRrqj0nal39WYLv/Hj vQMU6SPqt5EQ7iOqt23ikx1CGupCyaR9/w19GD96M3OWgcpSVftrmzD6i2yFfiU9KIRt N+wue2BJAUC27/F9y4zPDqLPCrX6/j0x8ebEtT4x6yX2kgk9PcqqxeJJUwAkw5nO5dBa 4ELSyB73ICpd4feCPzHXSTtIwr30vczEYVooUlcNBRyy34u58WoCrjYjxWqa1o9IxEbr 8b0kWtEMb2nfQc6/9IhuQeWtWw8tBRFpS+/zYsMXLFCRFPAFAC6LfGcN9VqHE6sbmJMP 9qDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+mHtiNXReAvMVXCIfRWKShF9VKoIMvT9jGDz5sHO4OI=; b=aXnNNj6id9EQkTzBsn+vh4bv3sQDkJXmSt50aFyCQTT6HnNvkEPF8dumL+0sGH8E9E f10ixB0xFAEgh5F8lrBrf3sOPHMhvxjuz/Ewcbgf40NKtrDhrTzG0BmLVLPKvsfEhRGB jHwu94wG/ful3ZgayBXECbv80PbqOIO0NmGy7u5gkrJoz4H4XoOdiRjYP9BJyqNDUmpG FubLuBJnfhgwybsHajkuyc1kSkWRQ9z1kAI5ktMg++w+dcM2iUad3uoMbSQvmDxnOoD8 uTbVcg1vTmROLsv6NKgsWRErZGEwUjq5apBhglmEngSECu3BQAjHXWYdWS+EXO64JHKO JSSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I3r1Nmzf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh33-20020a1709076ea100b007a9c3366e9asi3505047ejc.716.2022.10.25.11.33.25; Tue, 25 Oct 2022 11:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I3r1Nmzf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbiJYReu (ORCPT + 99 others); Tue, 25 Oct 2022 13:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbiJYRer (ORCPT ); Tue, 25 Oct 2022 13:34:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C3A193FD for ; Tue, 25 Oct 2022 10:34:45 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 3E27D61A56 for ; 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- mm/khugepaged.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)); base-commit: ec24a700584c4df869282bcd92b6d88329afe395 -- 2.38.1