Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1946423pxb; Fri, 22 Oct 2021 10:36:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFZ/XNDRk11NW4S6e/dM1gZTcQKAPhuzVlxDe1JMb72ABfjr14Vy7a/obj1T8tUSH1Jxkz X-Received: by 2002:a17:90b:4f88:: with SMTP id qe8mr1348881pjb.223.1634924204458; Fri, 22 Oct 2021 10:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634924204; cv=none; d=google.com; s=arc-20160816; b=0aMZiBm9EB/bC7mpRDLGxPGtqfqwW4vaS2Fdj7VHBJEAbnkeBXm0gBqufmpCAGm+3m Cay2uTRBZGt/gri9cwhl2q/8YLP36YhoCBt9owdVR3022+YarM3PID9zjr269P8eMgF7 cMt7S7V32/dMPWqy6W5dgRMYpScf/gBU9RM5iJ9uYEDZ6gUY8FTCyoOFtBk2w9aE7XsZ +qhGLUPoO9AD6tg3XBIlNQXGzNWv5nvd8KmbX/0kpsD4x3rv89j9U0aEhyE6zA8LkFxU nQcauermOXNTjjGRRU4JuaBwjt92pqrOmxmSt6CdJinSW1OxgrVbMv+YSrkohFp+HS1O Yqug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0LsY62/6ngRxgBm83XOe/sLH1xiASl+MCqBfNsQpWM4=; b=LYK4kjKcyKiCmcV8aitLyX6+v2Sqga4kgaDqKDRDwcSQtaMN7MoqDwH7zN8YPb/vob fGlQX9bkZXsnfV9eA3XxrFREIKgVgmEsJZ/wKzBbAT0on0WT3Ix3Fqu1zFvgt+U9jisT reQZGfJjNmDAiDkdVj5ptc0qTNtKYY2Vl6SeBhvi4R8JN7GDMuO49XhcbVzzUspsZQxh kX7r1NY+iP6toXi820ymPaWChtg8h9eUSfwUm6ldDO64zS+Ub7vo4jF3Dv8oaKGnUGUb aXJtebexvaDt1h43/JTH5bA7SHs/ntBlcYNtCUbSPQIKE6gcwoyG95wShYDpDoAgCl2K MQ1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OrVfoA3X; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si1208108plc.205.2021.10.22.10.36.30; Fri, 22 Oct 2021 10:36:44 -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=@gmail.com header.s=20210112 header.b=OrVfoA3X; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233538AbhJVRhq (ORCPT + 99 others); Fri, 22 Oct 2021 13:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbhJVRho (ORCPT ); Fri, 22 Oct 2021 13:37:44 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB72C061764 for ; Fri, 22 Oct 2021 10:35:25 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id t16so8026660eds.9 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=xAUy5csXpJVEw6XtpgysEtkoXa6mKpAiXaXgbRtDVOHRVlqZGzXFms5NC2Ep5+XfXh L0FWQ6lkhxccKpjckivQeIm5emYJv5tUJ31d8yJya0xGk1OmnZET45ZaKgfwjsf6NItv /Dp5+0xpwVqYn/X7HKwI69cU0l6j7n7QjGuLZsByyoMen/o9+0wrpyAuYlwNRBCxqyYj cJBvxt3tgj/AWTiEDRA6eeiBDI1YFp/Y2/LLYjxUnutfK0MEkxaES+1e8VwYriOiJ4Jk Z7afLihaYjJ4E23OvfggD2ys1cthxEXZpnPL9jc6VlKJS/Dk+oHM4rgXc7xCWopHgGpw Fixg== X-Gm-Message-State: AOAM530qG0L2hJBdMUOzQIKEZbxauYrw/xgjKZYT00ewpjSN8hTqSOKJ nrYsrTetXqPUrKT5+E9weqZldg5x2a0jP/b7I1Q= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >