From patchwork Thu Feb 2 14:15:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 649895 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 D1DBAC05027 for ; Thu, 2 Feb 2023 14:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232176AbjBBOPz (ORCPT ); Thu, 2 Feb 2023 09:15:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjBBOPy (ORCPT ); Thu, 2 Feb 2023 09:15:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC65E3A7; Thu, 2 Feb 2023 06:15:52 -0800 (PST) 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 91EB9B8266F; Thu, 2 Feb 2023 14:15:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3434C433EF; Thu, 2 Feb 2023 14:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675347350; bh=cliceGEpDPWRRZ/wPbCTq+b7JfWhyfm7xM7yP+3Udss=; h=From:To:Cc:Subject:Date:From; b=L3XCC+RB6OLs+dem4JWYjTEKK6dYVsNb3Ub6C9fxSg2Yagggn33cxyAheZ+HLh6HY JBcpf32VTpJsplj0/6KYRTSXuFcL3/lfgyrfRwS92rHH+Q1Se4QxHxEEiN+PSUwSZs BDKKI6H81XKsdbx4ZUlUhc3EyQNRN4aAKWHbebxw= From: Greg Kroah-Hartman To: rafael@kernel.org Cc: Greg Kroah-Hartman , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers: base: power: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:15:45 +0100 Message-Id: <20230202141545.2295679-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1289; i=gregkh@linuxfoundation.org; h=from:subject; bh=cliceGEpDPWRRZ/wPbCTq+b7JfWhyfm7xM7yP+3Udss=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3j04UzD2tfm2DYJSIxnIPDe03LgWHl6aFsT5Zkz2FXa7V VDmyI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACaybT7DgmuzIg5mqHlnyWTcyF/xMr 9Ms/7XRoa5MktCfzTfTXKw+/g46SyTa9c5R4tlAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. Cc: "Rafael J. Wysocki" Cc: Kevin Hilman Cc: Ulf Hansson Cc: Pavel Machek Cc: Len Brown Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- 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 967bcf9d415e..6097644ebdc5 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)