Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19061867rwd; Wed, 28 Jun 2023 04:42:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Q3jMSDhKMRmklpGzDvWmZT/as/vUcQ3W9us/A2kmef6/s7VqWYgfbPWS5zDOBeQd/85ZQ X-Received: by 2002:a17:902:6b87:b0:1ad:f407:37d1 with SMTP id p7-20020a1709026b8700b001adf40737d1mr7030255plk.52.1687952543251; Wed, 28 Jun 2023 04:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687952543; cv=none; d=google.com; s=arc-20160816; b=d+zpJgO8YNE7xo/gxQgzVITfBp3hpjZofCv+HElaSyuV/xrRVfEZpxfuYbp+7ywzMs Hkzt0RqCFVjTMkQpwbFAgRoLvDZ9B3yUIwVZNyv1sKg7T0FtgNuzZnQiwgLouClpAGH+ 6zyiKsuM8Q6aRsdJsoLqgQgaJn/unhcQMnpXw8zMlaWQn1zcdxqPp0K/QvicCWTTz+E/ WYoGAKy9jv5TdFD8K08LgpFgw7Hm2Hbu30dh8bAU1Yz+Dz2MumsBll0Ctws7OjNas+o0 0wtCtWoFlCXZwIcFPZYI3+TSYY33jPV6JMgy4eQTVa0/NzN6/6EfJuzoI9XKACAHOaJf lyjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LJNGxl9HE/op/UvV9uxTchIpSoF3Zhq6YcpqPw6wBuE=; fh=fQ52+qL8LGFxkwsy0FbARfrWDF1wkHdgbXs9A7uHEqU=; b=HK8QeO5kjpxtkBlFpVOhZSiCbORytBx01B7G5VOpWWMo2EHLMfPUbpA0CasdhCt9Sf mAATEhgAXbJWwrQ8NIY2S8iF/OBKAcke4P0m8tD7ND9P4hf3nJvl1O2k5grdx3bPieW0 qr2z/JerONJAkOJbE8EFIfxgumA03C7BOkxXdZ5I2qp1O2W/HNSRfNGMw4NaaVjIBG6g SBXwYoqNFlHJY0gvzuJGUfzLqV+3SpAeNyQzpheTMc5nmU42C21JGmWkr+LxQ2i56Ob1 W1RnrjKLKO4J/Ml/heLtboQhdSwCLf0VZTqCaTU6AbrMYL4/WPI+GKWWuJncYdSN7jzg yQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vc62TVnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg14-20020a170903060e00b001b841d408b6si672889plb.501.2023.06.28.04.42.10; Wed, 28 Jun 2023 04:42:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vc62TVnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbjF1Kwk (ORCPT + 99 others); Wed, 28 Jun 2023 06:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbjF1KwR (ORCPT ); Wed, 28 Jun 2023 06:52:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2FC28F for ; Wed, 28 Jun 2023 03:52:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 044756124A for ; Wed, 28 Jun 2023 10:52:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11BCAC433C9; Wed, 28 Jun 2023 10:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687949534; bh=XOk+D0ptRLMiKQhTIq0ppgcPPwQq7tyALdYYcUu+pjQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Vc62TVnKNu+AsmUZlVev8f1ajPfxYoCSc+Ez6rX7BtIKFXY7tLhtKc/RXtVjyBfqW KW7HcEhl2YN7vsr6oRjWMuj48tZOkUAWGL2ZREe5I9KdDr2sU64RuKiKozLxCQMGrT V+4sFzIN5SOoBEKa9CFwUfZ5dOPD5SEbr6nzcrl8= Date: Wed, 28 Jun 2023 12:52:04 +0200 From: Greg KH To: David Woodhouse Cc: "Liam R. Howlett" , Linus Torvalds , Vegard Nossum , Andrew Morton , "linux-mm@kvack.org" , linux-kernel Subject: Re: [PATCH] mm/mmap: Fix error return in do_vmi_align_munmap() Message-ID: <2023062852-cyclic-presuming-6490@gregkh> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 28, 2023 at 11:42:45AM +0100, David Woodhouse wrote: > From: David Woodhouse > > If mas_store_gfp() in the gather loop failed, the 'error' variable that > ultimately gets returned was not being set. In many cases, its original > value of -ENOMEM was still in place, and that was fine. But if VMAs had > been split at the start or end of the range, then 'error' could be zero. > > Change to the 'error = foo(); if (error) goto …' idiom to fix the bug. > > Also clean up a later case which avoided the same bug by *explicitly* > setting error = -ENOMEM right before calling the function that might > return -ENOMEM. > > In a final cosmetic change, move the 'Point of no return' comment to > *after* the goto. That's been in the wrong place since the preallocation > was removed, and this new error path was added. > > Fixes: 606c812eb1d5 ("mm/mmap: Fix error path in do_vmi_align_munmap()") > Signed-off-by: David Woodhouse > --- > mm/mmap.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) Reviewed-by: Greg Kroah-Hartman