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 4CEB0C64EC4 for ; Fri, 3 Mar 2023 21:49:43 +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=PDJENOMA2Dyyztlobmx2w6xtPTqETsoHe2/FUQG+vYM=; b=KVHbSeoOOcttAS UO+bD8qOalS/sS2rGlS4xrmjITkSAmsNVUtyvOpEtpoZJK8G/ZFoSZjQPXBCrfZxSzoN1IJ+Qfw4F vYPofjuHvpKLVPcRDmUdjL/rJp5e53FTN7AXYLFm5cuPKt+sgPnaRemqjMT7Y/R2f0Rt3jP8kdvvM QpMJZXx1kQKfe2wuYlsdkV0E2+0FM0LboDyVcOwdq10Xm2SiD2vLW4PF+H5wYZ+YoOunZ22lVNOAg cnj2UCnso6ampD+uOKz+OW7yq5J1LlVRQvw+/SaCz6pLIVeXQ8KAs4y0flGaWbNED1vfBesC2uMlA WO0p7dIZiuNVtbqUWTag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYDGc-007Z4G-8C; Fri, 03 Mar 2023 21:48:42 +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 1pYDEj-007Xud-C8 for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2023 21:46:50 +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 0A51DB81A0A; Fri, 3 Mar 2023 21:46:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBA6DC433A0; Fri, 3 Mar 2023 21:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677880003; bh=Jagds/6lQ7/HQgX4stxgiiZoEl48T9QG1XVSQgt4wCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YgRdf4yq8paKtVYwalLAtWRCMcnlFH/7ksZK3ET5ab6WOJk7aevgnmz2iMqrM6hca prj+X0Xg53q9yx2WtFCb2mvx1cW0f8MGkKxoenEKa9bbF/JSJ3N679tvR3tqgVRyBj bXDXh2OazA9lwCAA9Y3DMleXOebF90wryllemrklSjJyDB9Ifh6SxheTYNgHCJ/x+p nF1H7iXziCAf0pcDMBq32LrCftd7yrbBARlZ+DXebi9nYlY9SeHOXXwywkhuVvhhEa YBZJoObCvTXz4gMg0Y8y/lPxGWt/wrDTRGzwkPeIwjikpd9siDIfiHLK7NwCQ68e/C yUsbbC6qvjyQw== 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 5.15 31/50] USB: gadget: pxa25x_udc: fix memory leak with using debugfs_lookup() Date: Fri, 3 Mar 2023 16:45:12 -0500 Message-Id: <20230303214531.1450154-31-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_134645_631849_BEBC19C3 X-CRM114-Status: GOOD ( 13.52 ) 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 7a038a681b7df78362d9fc7013e5395a694a9d3a ] 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-11-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/pxa25x_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index a09ec1d826b21..e4d2ab5768ba2 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1341,7 +1341,7 @@ DEFINE_SHOW_ATTRIBUTE(udc_debug); debugfs_create_file(dev->gadget.name, \ S_IRUGO, NULL, dev, &udc_debug_fops); \ } while (0) -#define remove_debug_files(dev) debugfs_remove(debugfs_lookup(dev->gadget.name, NULL)) +#define remove_debug_files(dev) debugfs_lookup_and_remove(dev->gadget.name, NULL) #else /* !CONFIG_USB_GADGET_DEBUG_FILES */ -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel