Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1411333pxb; Thu, 21 Oct 2021 23:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHmVHl5CU63Iv0FaRe88N40Dd/4tEhsCp6gy3T9uJpwXlT4EsYPUkbU07sT4un5s9R5PwW X-Received: by 2002:a05:6402:5113:: with SMTP id m19mr14953901edd.231.1634885407907; Thu, 21 Oct 2021 23:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634885407; cv=none; d=google.com; s=arc-20160816; b=V/N0o3ppHnkEIXmdykBjCtRz/uFODd7JTrLNHCMLwN2MSZJAsxTNjNTpONYhy93UUF JsVsHaHFqwnEeRKwH+4Y+Dbx0tsznWooErfZGpmL5ByaYec4kU2bh2Xd2xciudqbfBQF dYU9H8E6+c+1uJBvHoe8PILEzHmkJwEzZlPUW9rk5VcmQYAMf+5LZpfUgNk0mfzEioQE B0J6Et09INKEyTLtu6UHEfomZqs4wtM3DtPKwrjGWjwngt8nUmEQF1OlfpFIib56ijj/ oyyR/47vlKUr2Rn5iE1Zu9ydA2YqDp132ioKOvvMaZMZkgYb1REMgcgm+PmwyYU7Qo1x OyBw== 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=0/hHaoxEtHWZsLFe52TiwK0ba8/z+kATcPwZNTldL8w=; b=DHscEp1pseYcIMsc7JpcLhkW4iM0LPSF+nUo8onpoYwJXR74J/lVUUQa3Mv5ydsBWp 8pSipSy2ns1QPBd3/FaVKvtvDGXQUBZbrDVb4XC27T04eOFyZoFnDN9ESlbeI7pNMOJp oM+66H5FemQH9lO7LDeOgw9BTWbVdiNty5LvFsYZWVyXYAPS8W9zrszpo/o66u5N0fIM Sg8ZrrlessjqRtJDksuEdkA+6c+PGzg4mgvQMnsVCKX4mvA/rVKnQH5bEzlTpd3dcqld y+3dXO/8xeXM5jfWt4TzfVnMX/1oYWWAzMRhwGYVwvzwPhV8Gfie/Rxjez73o2ccae30 hfBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IIA5uKpi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si5259066edo.513.2021.10.21.23.49.44; Thu, 21 Oct 2021 23:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IIA5uKpi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231898AbhJVGuL (ORCPT + 99 others); Fri, 22 Oct 2021 02:50:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:58282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbhJVGuK (ORCPT ); Fri, 22 Oct 2021 02:50:10 -0400 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.29.2