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 36A35C64EC4 for ; Fri, 3 Mar 2023 21:48:42 +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=PpLsBRd5UDcWdYdMFvYXBSGrViFj4BcUu/ts/zLIfEY=; b=td5wjixsPOwzlM fopEE2eRHlXLPsfkTOoUxdCsSXlA4PxbGf4Csesu+gJ1lkUj2sKNnUIhZvAyNwZH3gNTPG3zXzc5c jLAf/5rpGJsXdW2kRRKUVUFCrgKsNukvsbGrhrA9+V9TYhcDIv7O6cL9CczHuqru0HEpqQGI9D/+h XNp79koSdJpUo9oNvEzpS2SYrnjMBE7dKCgYiRGdTYbMJHKb6yKexJXXb3R7+g0JdJHB/DWBB+9v6 4GP+6/AjM//Otb/g2zNDEQQ9xDs7CYsQiMnnQita8DFOW8DQ3ES/Yt1jspRku2wxIoxfH4K5/CATY wHAnuLjh3eaH3bmDnMsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDFe-007YPk-Oz; Fri, 03 Mar 2023 21:47:43 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDEi-007Xu1-60 for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2023 21:46:46 +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 ams.source.kernel.org (Postfix) with ESMTPS id BCB36B81A19; Fri, 3 Mar 2023 21:46:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BAA7C4339C; Fri, 3 Mar 2023 21:46:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677880002; bh=WXPFuf2BUqghGATTpXNUiw35r1ss6M1T+j0ny9/nWz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LpkK+hno2sDohmEaPdlva50l328M2fF+U0aqo1GW9CegMM+CuFzVvtdXiNeukXBBB CzZmwuPnKmfUtSMxYbUo7oH8WA1YrivaAbNyth9xbJvXsVp1t3zbHpkOJNFE2sjE5P nQgE7bfpgu3b94x1m+FqPWbVD/Bwev85zp2bKOdmunZQ8MTZIX9190mm7HqoPepFGP Smc9bzXIPvSZUWjznEf7wWnM8ty/V++IV2JdBeML7rs6z98JbrZzxIgDpgrwMipjAO DP8Rl7IgcjLaaFsk+GFBLcscrpOg36fuBl3kmoA+HWTPRd+UjtMmgKi4WJ677KqhBv 7sgpVqMcIjDFQ== 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 5.15 30/50] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:45:11 -0500 Message-Id: <20230303214531.1450154-30-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303214531.1450154-1-sashal@kernel.org> References: <20230303214531.1450154-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_134644_426078_5F707F5D X-CRM114-Status: GOOD ( 12.61 ) 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 865de8db998a9..ec0d3d74d66e2 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