From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B804BA3E for ; Tue, 7 Mar 2023 17:40:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84FE3C433EF; Tue, 7 Mar 2023 17:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678210857; bh=iyW7J75hjX7cWbNuHpowG7RnPTkdZtA6yC1o3R8t1yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v0ejh+8MezmpFvfzMxDqZVzmcIK8zOzd6MfSO5Ocw/OwkWuqREiUsHPBnXsK70yw6 p0Wy8DI0EbkBd+InaZPjUva6P/BgZSNotPB/DkODxGruX47OjihbizE1X48gW2xBGs BaJlOGfR9KyFl8YVgR574SieO15cKT4LOvVFzB8g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ulf Hansson , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.2 0676/1001] PM: domains: fix memory leak with using debugfs_lookup() Date: Tue, 7 Mar 2023 17:57:28 +0100 Message-Id: <20230307170050.924185211@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170022.094103862@linuxfoundation.org> References: <20230307170022.094103862@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman [ Upstream commit 0b6200e1e9f53dabdc30d0f6c51af9a5f664d32b ] When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once. Signed-off-by: Greg Kroah-Hartman Reviewed-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 967bcf9d415ea..6097644ebdc51 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -220,13 +220,10 @@ static void genpd_debug_add(struct generic_pm_domain *genpd); static void genpd_debug_remove(struct generic_pm_domain *genpd) { - struct dentry *d; - if (!genpd_debugfs_dir) return; - d = debugfs_lookup(genpd->name, genpd_debugfs_dir); - debugfs_remove(d); + debugfs_lookup_and_remove(genpd->name, genpd_debugfs_dir); } static void genpd_update_accounting(struct generic_pm_domain *genpd) -- 2.39.2