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 32488C7EE3A for ; Fri, 3 Mar 2023 21:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232403AbjCCVqM (ORCPT ); Fri, 3 Mar 2023 16:46:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbjCCVo4 (ORCPT ); Fri, 3 Mar 2023 16:44:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E646265C63; Fri, 3 Mar 2023 13:44:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id EA05F61919; Fri, 3 Mar 2023 21:42:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A685C433EF; Fri, 3 Mar 2023 21:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677879754; bh=ud9bS8BBNwLLLwu18K43YklUIaPteLlRkmPLAfIeqBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XD9cvrbgtls3CdF7Cg12q6OS0RsOgXpi9e9lbSX7GSIkkPmnIfp7fFmeDQfR+XJ/4 +YX4FtRFPTmnBBWfylJl/3uoLp96QMZ9t0nlXBaQ/+DodC6wMKB9gRkWuwSxD7t6z6 69Yv2tfXj0ujPjA6L7fz/nx5wkXZ6dJnomZRwCb8CyU5TAEzTo5C1HsmcvTRhZeQTf vZG7mBR2cZUzZN94dEBfRBSTJNAhwcwQlBGO7VQCBNwnwI6C1anw47CwCU+7DFhvy1 c3LQKymR7IRr9w70psrPTgKEhXM+8VyBxETMsTG4ngQQ1GmAuMT/xT05VV5qpRlIeY 64CKSzKuMoCbA== 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.2 40/64] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:40:42 -0500 Message-Id: <20230303214106.1446460-40-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 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 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 E3AD5C7EE30 for ; Fri, 3 Mar 2023 21:44:00 +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=nXs8q4VooTK3SJ InAmRRJ54+uu9R9U6drYGpchv48alB9Wvu+9vvbBHXa9fjHn13gdOCuSBZNMe3pRDs7FE8KVOXMw+ j5p85N8HWEDX5Z59UZZrJ48H3JJP2fUrVYLK1l0iCh0MShpX+QihEDsvLO+wJ159/VPwAy1JM5OGd 6E9Jk4ygGskKjI3UXufhi04XNikAR+PfErGH9bcZ41hqHCT338LIofilaJR8CDeJaLgzNM+eNJllU d1e17UWFVl6XPFGi8dU8RTITOyjMTihyafr9LhYR8O1rz/sw29jUNI9I3UTUsjSC10h1+pb88vYDV vfWdZ7gPksSe/n4Kb+0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDB6-007Vu2-Lc; Fri, 03 Mar 2023 21:43:00 +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 1pYDAh-007Vjq-HQ for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2023 21:42:40 +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 07D4061947; Fri, 3 Mar 2023 21:42:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A685C433EF; Fri, 3 Mar 2023 21:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677879754; bh=ud9bS8BBNwLLLwu18K43YklUIaPteLlRkmPLAfIeqBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XD9cvrbgtls3CdF7Cg12q6OS0RsOgXpi9e9lbSX7GSIkkPmnIfp7fFmeDQfR+XJ/4 +YX4FtRFPTmnBBWfylJl/3uoLp96QMZ9t0nlXBaQ/+DodC6wMKB9gRkWuwSxD7t6z6 69Yv2tfXj0ujPjA6L7fz/nx5wkXZ6dJnomZRwCb8CyU5TAEzTo5C1HsmcvTRhZeQTf vZG7mBR2cZUzZN94dEBfRBSTJNAhwcwQlBGO7VQCBNwnwI6C1anw47CwCU+7DFhvy1 c3LQKymR7IRr9w70psrPTgKEhXM+8VyBxETMsTG4ngQQ1GmAuMT/xT05VV5qpRlIeY 64CKSzKuMoCbA== 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.2 40/64] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:40:42 -0500 Message-Id: <20230303214106.1446460-40-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_134235_692178_BC1D084F 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