From patchwork Fri Oct 22 06:47:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12577135 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 312BAC433FE for ; Fri, 22 Oct 2021 06:47:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C11A36112F for ; Fri, 22 Oct 2021 06:47:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C11A36112F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2D331900003; Fri, 22 Oct 2021 02:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 282F7900002; Fri, 22 Oct 2021 02:47:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17209900003; Fri, 22 Oct 2021 02:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 049D0900002 for ; Fri, 22 Oct 2021 02:47:55 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A61311838A425 for ; Fri, 22 Oct 2021 06:47:54 +0000 (UTC) X-FDA: 78723143268.10.57B4489 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf26.hostedemail.com (Postfix) with ESMTP id 4AF3D20019D7 for ; Fri, 22 Oct 2021 06:47:55 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CDD860F50; Fri, 22 Oct 2021 06:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634885273; bh=j+A3hXIyh6wwO3xTe/afg7vjWoz+VUdDqxC1TFMrp3k=; h=From:To:Cc:Subject:Date:From; b=IIA5uKpiECH9A7MHonzFCOH9FqxhmEobyME1JhdYrlQ7V5+fu0sC598FX8UCaJdFE i7Co8rMZX2gjTHk4IN024x+CEYQPa9vKxEFufKaXwYjZX3PY+gRRFZNyts8/psfQKM 4FD6j3FieJTVG8EJIeorTCGVaphtK0KOOXnCgG8asJydXPkancG6G3LKtqiIJzh24h L5mGkbyHa2qLuo0ftL7wpiDZd2ogw2u2Ob+0HDMdJIiLy00QQUJ98FKY98XaqCqTrL Qs9SKSEnWxYF1DIQ2/yxHJi4zjKbjuIuMWwpfy3bgVqWmIWVXdFehCQZUEi07EuwUZ U4KoxZYhDD5xA== From: Arnd Bergmann To: Naoya Horiguchi , Andrew Morton , Yang Shi , Stephen Rothwell Cc: Arnd Bergmann , Oscar Salvador , Miaohe Lin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: shmem: fix uninitialized variable use in me_pagecache_clean() Date: Fri, 22 Oct 2021 08:47:36 +0200 Message-Id: <20211022064748.4173718-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Stat-Signature: oc4fp15upzozzd7wojnxmifhcfx87bnr Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IIA5uKpi; spf=pass (imf26.hostedemail.com: domain of arnd@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4AF3D20019D7 X-HE-Tag: 1634885275-183524 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: From: Arnd Bergmann It appears that the has_extra_refcount() is now in the wrong place: mm/memory-failure.c:892:6: error: variable 'extra_pins' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (!mapping) { ^~~~~~~~ mm/memory-failure.c:915:32: note: uninitialized use occurs here if (has_extra_refcount(ps, p, extra_pins)) ^~~~~~~~~~ mm/memory-failure.c:892:2: note: remove the 'if' if its condition is always false if (!mapping) { ^~~~~~~~~~~~~~~ mm/memory-failure.c:879:6: error: variable 'extra_pins' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (PageAnon(p)) { ^~~~~~~~~~~ mm/memory-failure.c:915:32: note: uninitialized use occurs here if (has_extra_refcount(ps, p, extra_pins)) ^~~~~~~~~~ mm/memory-failure.c:879:2: note: remove the 'if' if its condition is always false if (PageAnon(p)) { ^~~~~~~~~~~~~~~~~~ mm/memory-failure.c:871:17: note: initialize the variable 'extra_pins' to silence this warning bool extra_pins; ^ = 0 In both of those cases, we already set an error code and don't need to override that one. Fixes: d882a43a0011 ("mm: shmem: don't truncate page if memory failure happens") Signed-off-by: Arnd Bergmann --- This is caused by a commit im -mm, so the commit ID is not stable. If the fix is correct, I'd suggest folding it into the original change --- mm/memory-failure.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 3b04f0361a58..e8c38e27b753 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -909,12 +909,12 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) * Open: to take i_rwsem or not for this? Right now we don't. */ ret = truncate_error_page(p, page_to_pfn(p), mapping); -out: - unlock_page(p); - if (has_extra_refcount(ps, p, extra_pins)) ret = MF_FAILED; +out: + unlock_page(p); + return ret; }