From mboxrd@z Thu Jan 1 00:00:00 1970 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 960C5C83005 for ; Fri, 3 Mar 2023 21:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232281AbjCCVoc (ORCPT ); Fri, 3 Mar 2023 16:44:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjCCVoM (ORCPT ); Fri, 3 Mar 2023 16:44:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523B58A68; Fri, 3 Mar 2023 13:43:20 -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 32A17B819FA; Fri, 3 Mar 2023 21:42:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BBEFC4339B; Fri, 3 Mar 2023 21:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677879756; bh=o2T0u/e0V3LqzENCHAw0Xh5SBmm+usjlUib11r6OMgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lU+rZzCX4yReQQO4wN83MDka4ak14tlA98osr9RI/1+DZv7JNCT7xspdTUXsl+SFJ C9t2aGD4U+NQ/8dWyt0MJ3aSBVXKvnmpGHVRwj7HC6eHqa5IavpK7LtI0QqejwLT87 cCVGw1viNQrbP/VVZF3vV3jtOMjFW7bstWDzSpT7hJdYU1NJjWQE0ZC+Okkp6Io3YF 0g0wjRgBNHl2sPZPnN5uHDHmqPBlSKqS+SEzhGWXfq5BeOkvYkqTzTXA4Tx5YfwZ/L Yc3xvggmxPPgTY8M51GcEuloXMaJdNGesebuTBhLZkFjsQD+JYrdVQt2TQfzDkPYt2 Lc+KriwOZ57XQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 6.2 42/64] USB: gadget: pxa27x_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:40:44 -0500 Message-Id: <20230303214106.1446460-42-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303214106.1446460-1-sashal@kernel.org> References: <20230303214106.1446460-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Greg Kroah-Hartman [ Upstream commit 7a6952fa0366d4408eb8695af1a0578c39ec718a ] 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: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Link: https://lore.kernel.org/r/20230202153235.2412790-12-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/pxa27x_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index ac980d6a47406..0ecdfd2ba9e9b 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -215,7 +215,7 @@ static void pxa_init_debugfs(struct pxa_udc *udc) static void pxa_cleanup_debugfs(struct pxa_udc *udc) { - debugfs_remove(debugfs_lookup(udc->gadget.name, usb_debug_root)); + debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root); } #else -- 2.39.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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 21EA4C7EE43 for ; Fri, 3 Mar 2023 21:44:18 +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=T8t1B4amehj8k2IxVrecp7qFar22uemFAbDiVx7j4E8=; b=lnhU1MeApwgGVW 8MQqPKElW+ISoglwEsh0SeaKSmMrpcGNysSf7ooX4+kgFAhLQlqgxDrLkZVwcdw9TVkeiCKp27Gsu IJU3XuqKsoBKoS0EOHH/r/bl7PagjtqNdY6KFSn0Fd5giDHlOzBLHgPu4lU7LlfFN9lXcw4y9ZtsU HCp18aBeROMjO6k6yJtKcAD6c/zLoGPzZxroluzWEHKFJVwRvwi3d5aLBkdhPD/veN6XIujFWTW5K FDQIAKmuHipb4XD8Sxc+XN2b7fwaBwoim9GngK3o+TPi3MOxfUvjIoe1GtvB7JwF9/Slpq5Ux29gF 7I1WPBgF4pBwwj40SlwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDBR-007W4B-0U; Fri, 03 Mar 2023 21:43:21 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDAp-007VlR-Je for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2023 21:42:45 +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 sin.source.kernel.org (Postfix) with ESMTPS id 43611CE229B; Fri, 3 Mar 2023 21:42:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BBEFC4339B; Fri, 3 Mar 2023 21:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677879756; bh=o2T0u/e0V3LqzENCHAw0Xh5SBmm+usjlUib11r6OMgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lU+rZzCX4yReQQO4wN83MDka4ak14tlA98osr9RI/1+DZv7JNCT7xspdTUXsl+SFJ C9t2aGD4U+NQ/8dWyt0MJ3aSBVXKvnmpGHVRwj7HC6eHqa5IavpK7LtI0QqejwLT87 cCVGw1viNQrbP/VVZF3vV3jtOMjFW7bstWDzSpT7hJdYU1NJjWQE0ZC+Okkp6Io3YF 0g0wjRgBNHl2sPZPnN5uHDHmqPBlSKqS+SEzhGWXfq5BeOkvYkqTzTXA4Tx5YfwZ/L Yc3xvggmxPPgTY8M51GcEuloXMaJdNGesebuTBhLZkFjsQD+JYrdVQt2TQfzDkPYt2 Lc+KriwOZ57XQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Sasha Levin , linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 6.2 42/64] USB: gadget: pxa27x_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:40:44 -0500 Message-Id: <20230303214106.1446460-42-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303214106.1446460-1-sashal@kernel.org> References: <20230303214106.1446460-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_134243_957174_D56EB48B X-CRM114-Status: GOOD ( 13.65 ) 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 7a6952fa0366d4408eb8695af1a0578c39ec718a ] 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: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Link: https://lore.kernel.org/r/20230202153235.2412790-12-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/pxa27x_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index ac980d6a47406..0ecdfd2ba9e9b 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -215,7 +215,7 @@ static void pxa_init_debugfs(struct pxa_udc *udc) static void pxa_cleanup_debugfs(struct pxa_udc *udc) { - debugfs_remove(debugfs_lookup(udc->gadget.name, usb_debug_root)); + debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root); } #else -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel