From nobody Fri Dec 19 16:03:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 644B6C38147 for ; Tue, 23 Aug 2022 11:37:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354292AbiHWLhp (ORCPT ); Tue, 23 Aug 2022 07:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357831AbiHWLcA (ORCPT ); Tue, 23 Aug 2022 07:32:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EFF375FCE; Tue, 23 Aug 2022 02:26:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0F198B81C65; Tue, 23 Aug 2022 09:26:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EDEAC433C1; Tue, 23 Aug 2022 09:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246767; bh=NkX0qgk5tZRIxs43a3xj1BCoIDnP/FbY0Ka00fh+t3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHVpOi/+e9acOyBGg3FMncpgwTp1ae02yA36e89viUwabJodinhhYabC5yXMgKCsR h68WKt6MX0M7dxOdBXZbo4mcx8y/mDZVUp5ewcsttxga/DC2b4VseW+IqT4sAGmQ/h Mh3/aOQ+oReuGYdljvKlzoO+HqQcmqHjOKLQfIAE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Andrew Morton , Sasha Levin Subject: [PATCH 5.4 196/389] mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region Date: Tue, 23 Aug 2022 10:24:34 +0200 Message-Id: <20220823080123.833921106@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miaohe Lin [ Upstream commit 7f82f922319ede486540e8746769865b9508d2c2 ] Since the beginning, charged is set to 0 to avoid calling vm_unacct_memory twice because vm_unacct_memory will be called by above unmap_region. But since commit 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces"), unmap_region doesn't call vm_unacct_memory anymore. So charged shouldn't be set to 0 now otherwise the calling to paired vm_unacct_memory will be missed and leads to imbalanced account. Link: https://lkml.kernel.org/r/20220618082027.43391-1-linmiaohe@huawei.com Fixes: 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap= _vmas() interfaces") Signed-off-by: Miaohe Lin Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- mm/mmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 88e686367776..8873ef114d28 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1860,7 +1860,6 @@ unsigned long mmap_region(struct file *file, unsigned= long addr, =20 /* Undo any partial mapping done by a device driver. */ unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end); - charged =3D 0; if (vm_flags & VM_SHARED) mapping_unmap_writable(file->f_mapping); allow_write_and_free_vma: --=20 2.35.1