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 93702C05027 for ; Thu, 2 Feb 2023 14:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232206AbjBBOTa (ORCPT ); Thu, 2 Feb 2023 09:19:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232110AbjBBOT2 (ORCPT ); Thu, 2 Feb 2023 09:19:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1DD8C1E9 for ; Thu, 2 Feb 2023 06:19:27 -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 42A69B8266E for ; Thu, 2 Feb 2023 14:19:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D18C433EF; Thu, 2 Feb 2023 14:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675347565; bh=KnwbQz85rWjqz+hLEZM33hkE3pw3OH0c20SYsWCSuzU=; h=From:To:Cc:Subject:Date:From; b=nIGqz7tJGv6F1L20Nh/+Tl5V50cONLA9FukNblG4cy56k6BMcqZbjWKikVp/0LBrj 0Sgn7V3zQxSHhk3OKzQTXcQzvADpyPbZ5coRI1G01Eq21vNLKNGfS0rryOmogXmLba fIlWfPlgD5ZtgzRHqhV/U5AUv3t6UV0yfI1a0Xq4= From: Greg Kroah-Hartman To: linuxppc-dev@lists.ozlabs.org Cc: Greg Kroah-Hartman , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Alexey Kardashevskiy , linux-kernel@vger.kernel.org Subject: [PATCH] ppc: iommu: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:19:19 +0100 Message-Id: <20230202141919.2298821-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=1279; i=gregkh@linuxfoundation.org; h=from:subject; bh=KnwbQz85rWjqz+hLEZM33hkE3pw3OH0c20SYsWCSuzU=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3j6Vb7y/YsYtZckL5o9fubhNcFP9M5eyzu9e1cF+d5GlT ht0TO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiFaUM8525LKI9JrNeP+nxOTjPft PbSvYSQYb50Qc2vmT0nVLO7LOXYX+c0+RjpXL/AQ== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: Alexey Kardashevskiy Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/iommu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index caebe1431596..ee95937bdaf1 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -67,11 +67,9 @@ static void iommu_debugfs_add(struct iommu_table *tbl) static void iommu_debugfs_del(struct iommu_table *tbl) { char name[10]; - struct dentry *liobn_entry; sprintf(name, "%08lx", tbl->it_index); - liobn_entry = debugfs_lookup(name, iommu_debugfs_dir); - debugfs_remove(liobn_entry); + debugfs_lookup_and_remove(name, iommu_debugfs_dir); } #else static void iommu_debugfs_add(struct iommu_table *tbl){} -- 2.39.1