Message ID | 20230202141919.2298821-1-gregkh@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp265482wrn; Thu, 2 Feb 2023 06:20:04 -0800 (PST) X-Google-Smtp-Source: AK7set/ZtfhpmureaT3P1izZThE5sS96x/jz+6WSxqyf8PRenHl/4xTXUBiwj+FIrYofTbu7SYht X-Received: by 2002:a17:90b:1e11:b0:22c:d77:8118 with SMTP id pg17-20020a17090b1e1100b0022c0d778118mr6391425pjb.39.1675347604462; Thu, 02 Feb 2023 06:20:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675347604; cv=none; d=google.com; s=arc-20160816; b=qLYjnDuEOjtTsP1L9NQSOaFw+KsPmvts6O0gEnZX2jzRH0Eh8o3pLmOgrRThLr/OpG l6qyBjPFng9SJztGOgB3A4cX9V78jm3zN1pK1XgFrbQT9WTPwHwext10g+EQ9n93CIMJ ZL61RxgWMcfQu4OK7FLEfu8pgvYHXaZUO1FCY5GQLzPteqFJEX2pROGqwKLYEfYZtKO3 qPFA9z4bJX7OZ5P89VUpG0GXXzZ4+WaXtNX+oqpFx98sZkqHLeWiXzkmeaJiRnUldOfD rAZqYMxXlTA+C/SVByVo4kxq3RkG8xb7n/wDZRfEDe55vgaVGDX8cQWyjOll/IOwIyO6 e3KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pXpXU+7/oskqoeYtcDAatCbVpt6AuekY3I509R4Ul5c=; b=pgD+kcaKuHCb2+eVoAypvXpyFonBWHNXp60cz44W+Cx0ApMrryITiLf135VdZ1ka7f ayMiW6FS2PJMYvucB/TuBlajaA3yuWTp38KY1+Eh9mBc7xzGRvJmMro/wbSY7c8dXJDy oqhimpU597VuJmP8ZMrbZXytLk8l448sZ5M6Onjiwq4e4T5cjk2cWp0lVkHsuG8CnJ/B HBNusBp1cXABm6XRL/5SGDevD54v8iet5jGGOUNIbQZV1keDq57oMRw3yoKCXkQRTEPJ u08l4lJpBHqL+7GhlJ99be44SJAfcOPhcNjZ3TlncpKQarwpcYGtlfdIlV+CCS5s5nU5 D2+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nIGqz7tJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d30-20020a63735e000000b004deff4cbbd2si22682736pgn.258.2023.02.02.06.19.51; Thu, 02 Feb 2023 06:20:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nIGqz7tJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232158AbjBBOTa (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <linux-kernel@vger.kernel.org>; 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 <gregkh@linuxfoundation.org> To: linuxppc-dev@lists.ozlabs.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Alexey Kardashevskiy <aik@ozlabs.ru>, 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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756729289335387315?= X-GMAIL-MSGID: =?utf-8?q?1756729289335387315?= |
Series |
ppc: iommu: fix memory leak with using debugfs_lookup()
|
|
Commit Message
Greg KH
Feb. 2, 2023, 2:19 p.m. UTC
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 <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kernel/iommu.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
Comments
On Thu, 2 Feb 2023 15:19:19 +0100, Greg Kroah-Hartman wrote: > 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. > > Applied to powerpc/next. [1/1] ppc: iommu: fix memory leak with using debugfs_lookup() https://git.kernel.org/powerpc/c/b505063910c134778202dfad9332dfcecb76bab3 cheers
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){}