From patchwork Thu Feb 2 15:32:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 52038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp313738wrn; Thu, 2 Feb 2023 07:47:39 -0800 (PST) X-Google-Smtp-Source: AK7set8/bWyzeixy1ZwaFunODDg3uetn2gDtW2ew1+xaPsZJXhRDUeh+jJNd1R4QELUsMjBLADjH X-Received: by 2002:aa7:d80d:0:b0:48d:91a9:2cd0 with SMTP id v13-20020aa7d80d000000b0048d91a92cd0mr7229628edq.29.1675352859554; Thu, 02 Feb 2023 07:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675352859; cv=none; d=google.com; s=arc-20160816; b=OpVlxAEpT1TmT6pDoy1Y2wZbd+3TG3xv6QldyK7stFFEi6HuafyMtKs3zOCJtXPfYC 0cbOCmX78b/kKrjYr71kkfRdrA1j3YVZvmPoCZ8B3CJ16IUzm2m3SaqH5Zf+vq44IsKc ZLw0lt4kDhW6JFLb9a6Hz0VumHKV66kUjVsv97T3+2eiURP+x4qRcRKHNiyt8Q4NsdVj KdxshAzCO+6RpZtWsYqELC1u1ycNlox2hgE9kX8mxHVeH4Eb54/TbXVpuislcKExy5Kq JqTXfSsxiWpVonGuQnHcz1tPQkDcx2G5Ujl0O9JLbbYAHj7Nw6PFnHvt2tJl/c2h0bhj 4ICA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X3BDSChQL9HZ/eDh0yMBznV0+nbzeYfjUnL0a/2Hibk=; b=eEAJ1m9GQbVx6lFwuE5K7BlArYM0W88hYIZft+Sjbg9Fd2kmZuNMzqy5aM82MFEQcR I/acwtm+5oJGUXJL+DKzBBAMNBaujyKT2W6xH5x7nsddd0rJ5fgQ2m6OUa970e6M1cTA 48BGnDDnv0sBOK7KfQkG8CB21bZJ7rPFxKCArxnSv8Gho1Fm/OvbI0MthaUx83othUTX TEjNBqXcxOr3ttjWR3BJ3oTi4CR8tW+cyRrEZdqKGII/I7eawwwPC45Zc9CXftOHWSPw aKzCPUINLqRnoF+eaKXdB6kF1O/sEN7HtX7bk5NJ5XFEsJu9xLPqQ4AmmfDXp3b/mYfW rZUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qbCmAFhp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a17090692c800b0088744fc7080si14330186ejx.401.2023.02.02.07.47.15; Thu, 02 Feb 2023 07:47:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qbCmAFhp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232907AbjBBPhS (ORCPT + 99 others); Thu, 2 Feb 2023 10:37:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbjBBPgr (ORCPT ); Thu, 2 Feb 2023 10:36:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E35C402D2; Thu, 2 Feb 2023 07:36:07 -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 E206DB826B8; Thu, 2 Feb 2023 15:33:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BF5C4339E; Thu, 2 Feb 2023 15:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675351996; bh=dnzVHu0pYh41EtriuTqveo6jeJTCVWTwi6pTRGgwTIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qbCmAFhpMCMfAQ1L9PcrMi6YUnf/FsvqFb3e/cthBO6vVhek73nErGby4VxR/yx3K AcyGoq0kLrBlSpcrUnyaW+oMXMElPci3M0JWnDhlxxbGDAZd2qEBsCKrMLHTQCjfp3 pKPoGv9Z/e2j3sCYKqsay4rPaXLkoh54hXffXuHo= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Kevin Cernekee , linux-kernel@vger.kernel.org Subject: [PATCH 09/13] USB: gadget: bcm63xx_udc: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 16:32:31 +0100 Message-Id: <20230202153235.2412790-9-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=1111; i=gregkh@linuxfoundation.org; h=from:subject; bh=dnzVHu0pYh41EtriuTqveo6jeJTCVWTwi6pTRGgwTIw=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3r09yD9rMHBIZtXdRWrCDhJvee/Pgx0eFJA/mqfFcVJCx rDvcEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABNJS2GYH6L89udlbzvPfR/kLxUHLX trFNXxh2Gu6AlJ24DNtc+Ec7n5xdN+Lf56Sa8ZAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756734799758273591?= X-GMAIL-MSGID: =?utf-8?q?1756734799758273591?= 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: Kevin Cernekee Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/bcm63xx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 2cdb07905bde..90cf78aa65df 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -2259,7 +2259,7 @@ static void bcm63xx_udc_init_debugfs(struct bcm63xx_udc *udc) */ static void bcm63xx_udc_cleanup_debugfs(struct bcm63xx_udc *udc) { - debugfs_remove(debugfs_lookup(udc->gadget.name, usb_debug_root)); + debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root); } /***********************************************************************