From patchwork Thu Feb 2 15:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13126423 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 45FD0C636D4 for ; Thu, 2 Feb 2023 15:39:32 +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=+jTFWx+KSatrt00jPWCWwhM5jXMCwYXj27ol5H35sUo=; b=e24K70SLsLV8QE 9VkW5ovSiyUOKUBwZi6ceSEdPn+5U69/QHmrpJctcuez7Bmqz8FtcxkMcSXcB9cXqeClnkPXExqy1 eVtyQ4sHsQ2J3v2fgN90zNk/kZDDO3bM+GJ/PtW+uLt364FKlMgRqto2YvSjFSssZH6Q2+bXa/nAZ b2QENGWiJ6bR+q0PI7LcOvYIreN2Fw8q5agBG7Hrc4bNevDgul26pOGMqA1an2tb6Sof4cWrzlly7 ndOKlpv2iNPppx3xAGGEZ/j3boFBsnBmEdjdOCkJuaFjkgTA19Q0VjNBXCn+4GpkqLLfOAIjoQLdf kByy6N8JsFptw8Qr5BuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNbfR-00GSgJ-18; Thu, 02 Feb 2023 15:38:29 +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 1pNbaT-00GPyO-AE for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2023 15:33:25 +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 A82FA61BED; Thu, 2 Feb 2023 15:33:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1103CC4339C; Thu, 2 Feb 2023 15:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675351999; bh=LxA279H1FvrJsAusP/AZ5gRL/bHuKKZsq2ugyns8LMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nI3g5+y7Skra/emw8kuhlV9ktB54HmaJDyN9sJzPlqo2gT+e3C4eBZPR45Q0u0aTR IFhRpwUt1zN7PyvBl4KkQYwzP378dY0AnGSMaorT+oBkD74KNcivMoZ12rtxkZhLND IpbzE1DsHQB4xwq9QJ/X3HcY9OlL3vNXM/yKZzzc= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Vladimir Zapolskiy , Jakob Koschel , Miaoqian Lin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 16:32:32 +0100 Message-Id: <20230202153235.2412790-10-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202153235.2412790-1-gregkh@linuxfoundation.org> References: <20230202153235.2412790-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1121; i=gregkh@linuxfoundation.org; h=from:subject; bh=LxA279H1FvrJsAusP/AZ5gRL/bHuKKZsq2ugyns8LMw=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3r086e3N95v++mDfTLTbt0d/4QEnTJjFWIcH9wqPd6inn b1mc7ohlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJLGljmF8ovfvh1wSfn47J/rqXPE Js3l270cawYI17wtnLkyWb380Kjgz0Fo07PCvkLQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230202_073321_486343_A38BCB86 X-CRM114-Status: GOOD ( 13.46 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: Vladimir Zapolskiy Cc: Jakob Koschel Cc: Miaoqian Lin Cc: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Acked-by: Vladimir Zapolskiy --- 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 cea10cdb83ae..fe62db32dd0e 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