From patchwork Thu Feb 2 15:32:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 52031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp312972wrn; Thu, 2 Feb 2023 07:46:08 -0800 (PST) X-Google-Smtp-Source: AK7set/t0hB9gm2I7mh76h1c5aQLwfhGRKpPypv47xQ7k2UhMS9110dlA2QZCIM5deN44Su3oDmd X-Received: by 2002:a17:906:cec7:b0:873:4ebb:94cd with SMTP id si7-20020a170906cec700b008734ebb94cdmr6913093ejb.10.1675352768040; Thu, 02 Feb 2023 07:46:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675352768; cv=none; d=google.com; s=arc-20160816; b=dm90CXxJ7EndGhljUjLmXgRz6/6Jyvl0umfiy3noflyz+94psgVvOD6eGO7duvbyFs CQ/o9Q4B3NBYF8IpYIbzGTibWQklfd8BWqZE9BdI6j5zMO0U0wc3CLO45DuuOLteZdXQ W288UqONQvfzWzIm0KnJKJIEDpR4mZKR6E1VtRbWt3q7E29+5smfb/W81DniUrTCxTlg v04Ujnca5J5bBg0E8LMF4bBV1pz7ZdIQhtIXCvBhFG6yWb2Id14VLSFLUjtNjxUS2H0Z Nx/YA1THzoNhcWX5qfocUudSFz0sFuzq7zQjc9zK2htWSoKr8ANVsEBYohYR2efyh+Cb TJ5Q== 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=WJikIEVjlRgCa1MOhzu0EX9ntzTIqWyjkURqFVdOEMo=; b=NyQW0OXIBxCEFbtwAPhD2laaamWJ4qZuJUrf3QsbK1XX6vhdB/8yxsMi2LY04/Kru/ RL7ZgDMziD23FRhzBajj5DgLEv1tWeXF7O88s1pTlvG2A3vFwY9J7jM5EHjaqGWY1ZID BbqmEjx/lXbFk+hdQodB3o9Hir2nTu3iV1ITqnvSQc0nw+lvTi7TRKHVGlySu/6KoTZP XbXnArljRhYpuviZd94l1stkOS2NYnbQdS15PeQxR1gOZ/cip5CyAZNhReZDYb8rIN9B sf/iirXYUzVt4wHoNfee8yjDIeN5kZgDqtiJWYJ3DEPQ2j85yu2NLcGL8Bup398CXlMg ZVaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KALluE7l; 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 d1-20020a17090692c100b00889e8de7ce1si13119062ejx.814.2023.02.02.07.45.44; Thu, 02 Feb 2023 07:46:08 -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=KALluE7l; 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 S233305AbjBBPfz (ORCPT + 99 others); Thu, 2 Feb 2023 10:35:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbjBBPf1 (ORCPT ); Thu, 2 Feb 2023 10:35:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26296E9B; Thu, 2 Feb 2023 07:34:57 -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 53041B826B7; Thu, 2 Feb 2023 15:33:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9486EC4339B; Thu, 2 Feb 2023 15:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675351983; bh=Qda/PQv4RqX7g5dgxLcjBeYi+1CYJvm2YonTqRTHp+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KALluE7lJtGUkrnFm20tyBKum8/w3TbICvviZ/It3rBf/4T+x5MOQTu4Co3Mp7DRP HVwrCAWzC0nkk6c7wLAlmtfCHRxkYrB9Zu1eqBYbJV2mOh6rHSXmQ0PVQNgnTV53rH k9SebNJCICbs7COFDLc91CaG9GPBBBfAPuOD6y8A= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Vincent Mailhol , linux-kernel@vger.kernel.org Subject: [PATCH 04/13] USB: sl811: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 16:32:26 +0100 Message-Id: <20230202153235.2412790-4-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=1041; i=gregkh@linuxfoundation.org; h=from:subject; bh=Qda/PQv4RqX7g5dgxLcjBeYi+1CYJvm2YonTqRTHp+g=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3r08sePN5rmds879195Im6Tst7F/gf63qZGBjj+j9Q5tP tIh7d8SyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBErKUZFjSoLnryeQODXe79UyKlxm 3nBRc4VjPMj3k5v+/JJDGv46VTpEQ/bGnWMgg3BAA= 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?1756734704062574590?= X-GMAIL-MSGID: =?utf-8?q?1756734704062574590?= 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: Vincent Mailhol Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/sl811-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index d206bd95c7bb..b8b90eec9107 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1501,7 +1501,7 @@ static void create_debug_file(struct sl811 *sl811) static void remove_debug_file(struct sl811 *sl811) { - debugfs_remove(debugfs_lookup("sl811h", usb_debug_root)); + debugfs_lookup_and_remove("sl811h", usb_debug_root); } /*-------------------------------------------------------------------------*/