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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB023C6FA90 for ; Sun, 11 Sep 2022 23:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbiIKXXR (ORCPT ); Sun, 11 Sep 2022 19:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiIKXXN (ORCPT ); Sun, 11 Sep 2022 19:23:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83C6B26577; Sun, 11 Sep 2022 16:23:12 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 20236610A4; Sun, 11 Sep 2022 23:23:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EC31C433D7; Sun, 11 Sep 2022 23:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1662938591; bh=PZCJ2Eusa2Nqhe0c6aDFdtESndG5NT96OZEjoj4Cr4w=; h=Date:To:From:Subject:From; b=FGFi6bVLikh0S5E6KtbYN4m9ViesHqGf5rm2odyMJ2UYSHZwlELKQXdXwZbnUa9l1 cDOHjc/u7hNYLRwmVaONkdCAYDIYedU9DBFm+5iO/quwhAy3CBbDx/MFA+hQilF/bq 9IT60EypDb7sU0f/yW84K5Kq8G0ZhFece+6422cc= Date: Sun, 11 Sep 2022 16:23:10 -0700 To: mm-commits@vger.kernel.org, stable@vger.kernel.org, sj@kernel.org, gregkh@linuxfoundation.org, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-hotfixes-stable] mm-damon-dbgfs-fix-memory-leak-when-using.patch removed from -mm tree Message-Id: <20220911232311.6EC31C433D7@smtp.kernel.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The quilt patch titled Subject: mm/damon/dbgfs: fix memory leak when using debugfs_lookup() has been removed from the -mm tree. Its filename was mm-damon-dbgfs-fix-memory-leak-when-using.patch This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Greg Kroah-Hartman Subject: mm/damon/dbgfs: fix memory leak when using debugfs_lookup() Date: Fri, 2 Sep 2022 19:11:49 +0000 When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Link: https://lkml.kernel.org/r/20220902191149.112434-1-sj@kernel.org Fixes: 75c1c2b53c78b ("mm/damon/dbgfs: support multiple contexts") Signed-off-by: Greg Kroah-Hartman Signed-off-by: SeongJae Park Cc: Signed-off-by: Andrew Morton --- mm/damon/dbgfs.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) --- a/mm/damon/dbgfs.c~mm-damon-dbgfs-fix-memory-leak-when-using +++ a/mm/damon/dbgfs.c @@ -884,6 +884,7 @@ static int dbgfs_rm_context(char *name) struct dentry *root, *dir, **new_dirs; struct damon_ctx **new_ctxs; int i, j; + int ret = 0; if (damon_nr_running_ctxs()) return -EBUSY; @@ -898,14 +899,16 @@ static int dbgfs_rm_context(char *name) new_dirs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_dirs), GFP_KERNEL); - if (!new_dirs) - return -ENOMEM; + if (!new_dirs) { + ret = -ENOMEM; + goto out_dput; + } new_ctxs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_ctxs), GFP_KERNEL); if (!new_ctxs) { - kfree(new_dirs); - return -ENOMEM; + ret = -ENOMEM; + goto out_new_dirs; } for (i = 0, j = 0; i < dbgfs_nr_ctxs; i++) { @@ -925,7 +928,13 @@ static int dbgfs_rm_context(char *name) dbgfs_ctxs = new_ctxs; dbgfs_nr_ctxs--; - return 0; + goto out_dput; + +out_new_dirs: + kfree(new_dirs); +out_dput: + dput(dir); + return ret; } static ssize_t dbgfs_rm_context_write(struct file *file, _ Patches currently in -mm which might be from gregkh@linuxfoundation.org are