From mboxrd@z Thu Jan 1 00:00:00 1970 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 DCBAFC433EF for ; Fri, 22 Oct 2021 17:35:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6DC676120D for ; Fri, 22 Oct 2021 17:35:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6DC676120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 82A5E940009; Fri, 22 Oct 2021 13:35:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DA57940007; Fri, 22 Oct 2021 13:35:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C8A7940009; Fri, 22 Oct 2021 13:35:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 5CF2D940007 for ; Fri, 22 Oct 2021 13:35:26 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 16AA639BB5 for ; Fri, 22 Oct 2021 17:35:26 +0000 (UTC) X-FDA: 78724775052.01.F023850 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf15.hostedemail.com (Postfix) with ESMTP id 35153D00009A for ; Fri, 22 Oct 2021 17:35:21 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id l13so4460459edi.8 for ; Fri, 22 Oct 2021 10:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0LsY62/6ngRxgBm83XOe/sLH1xiASl+MCqBfNsQpWM4=; b=OrVfoA3XmZ4DoVxt5np5xkuJvsdRgNM+UFT10jbqCO3nX6qm4x6HQEA90/sCdygDpT x9L4JL2uMUZ18jS201ebx2cgl272C+5+vU+Blj+bNf79jatrZLRlDsJuS7vNohx0qIGF ro6/INmr/McVV3fEDqZ1PIQsvaGRv8KHvuJBqDuPqWw8W65RoBw+9wAxgKCv0GrLEsck jQf21P4eOSh90YUHDt7aDPjg/5R+cvkH16L4iyVxw7xAPMhl7Tkt9Yh6RhtlL1Nkv9XC gmC/BpTTcEvbRjfacy910dNPGtq6M0jDgg88m9UMpMTy8DzXhFljy3oOUO2wnip82QEH 9TMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0LsY62/6ngRxgBm83XOe/sLH1xiASl+MCqBfNsQpWM4=; b=xqbfE7HYu8DM+omL2gW7gJ0MhDm1N7whyzbovvpRXqQwygZQ/wVcp95A69dAL6sXPu 6e8uAWX5sZikhVP/jpVsjzWqcaVj3B1xvFSmJUDHERdSN4X649hZjGg16fabTzHSc0gK +R353d3JBMinsPdmZfkvJxl13pCf1L55sxG3fwFknHP2I24/L1I7S+CVAuFLU48pY3kf hwZ8CVx3ldFgxtOp1vltJLw1DP87O6biU4kR2z8MSNVbLy55Iwd5J37wAMK5sN52/4fq l/vveiRO7b6l0pUQ6OMsvyF911bg15nTCgVDwza++17WgfSXJhbF6NUM8pF7EJglynNO EWIA== X-Gm-Message-State: AOAM530w7D7wQjBNlJA44cIIkhZFnne9xI58LP+2Wg+uoMICO86S2TDj cMb8vj3lh+l424tKMZQht2ruZvwF59GyvHBHTvA= X-Google-Smtp-Source: ABdhPJxxf08bQnWK9iyBxH6jyfKFHYh+LVlZXczmhWgCNu3dgWfTfUnavjgLaGgEBdD9QI3Y2JliEFvL7gZNv9sWBe0= X-Received: by 2002:aa7:de83:: with SMTP id j3mr1809459edv.312.1634924124380; Fri, 22 Oct 2021 10:35:24 -0700 (PDT) MIME-Version: 1.0 References: <20211022064748.4173718-1-arnd@kernel.org> In-Reply-To: <20211022064748.4173718-1-arnd@kernel.org> From: Yang Shi Date: Fri, 22 Oct 2021 10:35:12 -0700 Message-ID: Subject: Re: [PATCH] mm: shmem: fix uninitialized variable use in me_pagecache_clean() To: Arnd Bergmann Cc: Naoya Horiguchi , Andrew Morton , Stephen Rothwell , Arnd Bergmann , Oscar Salvador , Miaohe Lin , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: afhwo5ng13qzejagsupzahsgdk6mmuss Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OrVfoA3X; spf=pass (imf15.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 35153D00009A X-HE-Tag: 1634924121-207620 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: On Thu, Oct 21, 2021 at 11:47 PM Arnd Bergmann wrote: > > 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. Hi Arnd, Thanks for catching this. There has been a fix (https://lore.kernel.org/linux-mm/20211021180336.2328086-1-nathan@kernel.org/). But I think yours makes more sense. It seems better to have the "out:" label after has_extra_refcount(). Andrew, Could you please take this patch? And either keeping or dropping Nathan's patch is fine to me. Thanks. > > 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 >