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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F32A3C64EC4 for ; Fri, 3 Mar 2023 21:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RTP3V0M6NXPxOFVrs5TAX59K47J9T0T76fDVzS7WYNI=; b=B7RMMNepU/V3Kg BuoTFmpRjFailvj392XSvvXaZS8tOSHustxcfCGKUerFvZRbA78l3/SkJzpZAshMiJGO6O46eIvot 2IL0cbOysSxZZgCmrKQCAn4vdahoAJ3At8jllhvcBkWQOLcaP8xGDXuGxEg8W10Gu6dfMH26Lmgcq 1rFc6Jcg2k+xqWgqb/lLNu7vrsnzQlveEY8zZva8l41tFNfPayTmUcRaLgWnFmHy4GL8GMJb7NMME +DY3EYLH+4AXwilY0Ousbs4/6Xqewz15Ob1bCVXvjwhd+1WjcE2d+kdEGbTXCXouvYAUd3Z+mTs6B HE94ouV9Ai1CMjdv3hlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDE5-007XZl-7m; Fri, 03 Mar 2023 21:46:05 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDCf-007Wk2-TL for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2023 21:44:41 +0000 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 45AF161923; Fri, 3 Mar 2023 21:44:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DEB1C4339C; Fri, 3 Mar 2023 21:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677879877; bh=ud9bS8BBNwLLLwu18K43YklUIaPteLlRkmPLAfIeqBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blreYikKCVAcrznSRuK2dJlZXLJZG2SYQfpn1a9ZMBOsjpZMjuRwCVOJoiYi6wnx2 azXFUnUp8Vx4oAtkgTXzOnzSVBGtfooeEQhvKkif+8pF5DkK2Ca1qtxJ2gd3m+gdE8 ab1KwoyD3KaqPxOLqmt2NXiYjBSC5fhRJPtvy7YPjLQFbucuuu69zi70L9jvA6NaGx y3uuVCy7ETpqdn/N2tTOdFv9v7TdcLgWLdOnV0iIi8fOt866COTYFxgZy0vwqTQCJX iNtsvkRmj7NZe5+Ke3QfJhsg06ToquqZm89tEEdVMuZPyslVABQHLudxJiYL2fjl7R u0CniuvZOYDFg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jakob Koschel , Miaoqian Lin , Vladimir Zapolskiy , Sasha Levin , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 6.1 36/60] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:42:50 -0500 Message-Id: <20230303214315.1447666-36-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303214315.1447666-1-sashal@kernel.org> References: <20230303214315.1447666-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230303_134438_017676_01F2A138 X-CRM114-Status: GOOD ( 12.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Greg Kroah-Hartman [ Upstream commit e3965acaf3739fde9d74ad82979b46d37c6c208f ] 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: Jakob Koschel Cc: Miaoqian Lin Acked-by: Vladimir Zapolskiy Link: https://lore.kernel.org/r/20230202153235.2412790-10-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index cea10cdb83ae5..fe62db32dd0eb 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@ -532,7 +532,7 @@ static void create_debug_file(struct lpc32xx_udc *udc) static void remove_debug_file(struct lpc32xx_udc *udc) { - debugfs_remove(debugfs_lookup(debug_filename, NULL)); + debugfs_lookup_and_remove(debug_filename, NULL); } #else -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel