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 X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A77EEC433B4 for ; Wed, 28 Apr 2021 21:26:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F164D6143C for ; Wed, 28 Apr 2021 21:26:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F164D6143C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 230676B0036; Wed, 28 Apr 2021 17:26:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E0D66B006E; Wed, 28 Apr 2021 17:26:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0591E6B0070; Wed, 28 Apr 2021 17:26:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id D9CF36B0036 for ; Wed, 28 Apr 2021 17:26:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9529C180AD820 for ; Wed, 28 Apr 2021 21:26:41 +0000 (UTC) X-FDA: 78083060202.29.79B8C09 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by imf28.hostedemail.com (Postfix) with ESMTP id 8E4B32000247 for ; Wed, 28 Apr 2021 21:26:42 +0000 (UTC) Received: by mail-il1-f171.google.com with SMTP id a9so5028363ilh.9 for ; Wed, 28 Apr 2021 14:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o7l9IIcxFbTcNjI/lVJy/EpURY/RPEveNoN2MojstM8=; b=mqEdKQbFcvoqKDS76//hW3eJJ847NaXt7dzadA734Txj+MapGmgRSooSa9ltUC1FLo IWwrauXRzvOawwNUOli6iyPoKio/uVfIAFAWhy1Kx00oIueSp3biuW47E/jCLywpVBuf CIsC/4SvH2IECG4U1917cE2PBH52u4Z23xg4VHTJz4NR1sHkYrERYJiFchVtW1SBS6HB nnscHh/CnCkq70vtTpI0AB66K5kBZ9lQ81Llop+GS7SQh05KusnQjbO6nA5aZTe49zX3 l+15Q0V/N09gqa8LAtb51oZLPw0Hlu3cCxGZValERqNpwmMpyt5pGqJHoCvgMotEIX3F NO6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o7l9IIcxFbTcNjI/lVJy/EpURY/RPEveNoN2MojstM8=; b=rN067j9Q7SRAZEUpAMuKr+LBvT1vLRFb9lwLcDY+j/L2YgnQa1uJu21cTMl6mL/xSC d7asV1iwPIyOIAB+8kZVBsEgUa6ROluAYMiAU4wJzJi+44FCikqvo0fgxSAFG0xHhEzt xwgK4CaYnj29YIkT+G66aIRfzMN+MnBR8jNTQ2VF0J2RQRT2RmcTCSVJ7BNjTOEmdb4p M7JiISf9OOmkM9Aq0c1ZSlw2S/j9txI8bDeZ+JRsJrYExWKicBEqjtqPGayv/cJ5zLAs j0ACbS9Da5RdrlmlWg38ZN0Te3oanPOT9wdnkxkGkVSbEcRUUKAcSpF0YAVTq5x4uDwm ZtCw== X-Gm-Message-State: AOAM533qghGoQVKfCeooPm2v/Q1Trvpl7UJs9fvM14waPcLESNBGFNVv t+DPE5hbU9WY9HEjVbTxbbKc/MZmqVQ7dBbqpBuyxQ== X-Google-Smtp-Source: ABdhPJw7CrFZibeylky/W9Lgj1mYBNImV7tGNZoPq5C5XZP9XSnUHV196AatCpSnAps5cmunP5rgeXn0A2rWMOr4mXc= X-Received: by 2002:a05:6e02:1a4b:: with SMTP id u11mr24482288ilv.258.1619645200469; Wed, 28 Apr 2021 14:26:40 -0700 (PDT) MIME-Version: 1.0 References: <20210428180109.293606-1-axelrasmussen@google.com> <20210428183943.GH6584@xz-x1> <20210428212430.GA6462@xz-x1> In-Reply-To: <20210428212430.GA6462@xz-x1> From: Axel Rasmussen Date: Wed, 28 Apr 2021 14:26:03 -0700 Message-ID: Subject: Re: [PATCH] userfaultfd: release page in error path to avoid BUG_ON To: Peter Xu Cc: Hugh Dickins , Andrea Arcangeli , Andrew Morton , Lokesh Gidra , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8E4B32000247 X-Stat-Signature: rz1oy57c1egkaqxndz81b97jfsefidgb Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mail-il1-f171.google.com; client-ip=209.85.166.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619645202-329825 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 Wed, Apr 28, 2021 at 2:24 PM Peter Xu wrote: > > On Wed, Apr 28, 2021 at 02:03:05PM -0700, Hugh Dickins wrote: > > [...] > > > > > + put_page(*pagep); > > > > + *pagep = NULL; > > > > + } > > > > goto out; > > > > > > All "goto out" in this functions looks weird as it returns directly... so if > > > you're touching this after all, I suggest we do "return -ENOMEM" directly and > > > drop the "ret = -ENOMEM". > > > > No strong feeling either way from me on that: whichever looks best > > to you. But I suspect the "ret = -ENOMEM" cannot be dropped, > > because it's relied on further down too? > > Ah sorry I just noticed Axel didn't really touch that line.. :) So yeah please > also feel free to keep it as is. > > If to drop it, "ret = -ENOMEM" can go as well, I think.. since all later errors > should always reset variable "ret". Although I can see a refactor which simplifies the error handling a bit, my inclination is to leave it alone in this patch, since it's trying to be a simple fix and especially considering we may need to backport it as far back as 4.14. But, I'll keep this feedback in mind and try to apply it as much as possible to my other series which is significantly refactoring this function already, so the end state ought to be as simple + consistent error handling as possible. > > Thanks, > > -- > Peter Xu >