From patchwork Thu Feb 2 15:32:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 52030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp312890wrn; Thu, 2 Feb 2023 07:45:59 -0800 (PST) X-Google-Smtp-Source: AK7set/oQBxrnf5yXFxxuqikRuho7GBoFGStOjFopwcGLhlv7wikjnizSmLZwGSbsuwQuGThlHZ4 X-Received: by 2002:a17:907:8c17:b0:88d:d304:3438 with SMTP id ta23-20020a1709078c1700b0088dd3043438mr7107766ejc.67.1675352759032; Thu, 02 Feb 2023 07:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675352759; cv=none; d=google.com; s=arc-20160816; b=pLv2pj7UH4T01KtQ3ubBXzskV0j/WlBNWj4J4u2emiu69Vz52svBnll4Fyzb0LiMEb fltxWiHGOye/jiRn2NOZ28WXNI2yUCuZRWjz5Wyn7X7l+itYPKsk2bzkWdyL1qZZe2Vg dp0l6ulMIbzc3NaUGDjNAVY22YNeM2pcN3CU5xgHxA7PmfIL6d746yYhZTk3v15Go3Zw CpuDttJqX5G8ujoes+l0hCgygvGp5pqoZWvraW99jewoHEfg5+Mn37AzQ94Zg0jKw50U btcvLKYLU4uGrrgctAIGyxw+ubcBBBf4qpiAYLEsuR4BjmpXzOQIvnABpvmHQOR4W2mD vyQw== 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=3muUsqxTjimSGeHgo8QeI7LoEbhr70XVRhFcl6vOgWs=; b=LRfWeRjDdLPWsk3PrA4i2BuOKoz1mWMXpsb3mc+ZJLQ/aiD1w7ejpmd8zShW86+f3e HoBpvO/y5ucOhh4WHQCMn/zvsfmO2fabPFabZ265AtuvRquCEywKxTflXrxGyEU08cPm MB7YopTtm3RWg1Ud8BIiZBfBSn7AHE+Vvhe74Szg5Uq88xTJZrCgpYSYAXAnMqeZsiwn bBVYceJE2ohOvb42R5YDxefHYSZj5n8Vi7UjSf4awRx1KX7rzId3+uBWwD0BaoA2jsas imPxYdhSXOuAOXF3HkIEIv8sTGc6Z3iqW6mhZc2ys5VlUhDvTLEsAX8TAnv0utaxyAKR 6XwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="R4kL0i/t"; 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 h5-20020a17090791c500b0087876646d4esi22740979ejz.471.2023.02.02.07.45.35; Thu, 02 Feb 2023 07:45:59 -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="R4kL0i/t"; 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 S231905AbjBBPfY (ORCPT + 99 others); Thu, 2 Feb 2023 10:35:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233327AbjBBPe7 (ORCPT ); Thu, 2 Feb 2023 10:34:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 226E86B025; Thu, 2 Feb 2023 07:34:23 -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 7B21961BE9; Thu, 2 Feb 2023 15:33:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78FD4C433D2; Thu, 2 Feb 2023 15:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675351985; bh=tIvo5TZOENRUN+V2jHoBHcC8wyCCjHYFP1TOGz+IonM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R4kL0i/ts2k15V0PqGI8yGeLgBGbiehaI86XRV8RMD3TVMYGJeqfiEpzYiQKPwJTT 9L9bR2Q+jx6vkMACOvXNAOtn4qSX3AiZGSGEQBUE22UwP9PQZ41WP+ZrNXNXoJKMte jdK9bm2C/bVGaG3jE4qubQ8/DQ70aXX/usDcOG30= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH 05/13] USB: fotg210: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 16:32:27 +0100 Message-Id: <20230202153235.2412790-5-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=1086; i=gregkh@linuxfoundation.org; h=from:subject; bh=tIvo5TZOENRUN+V2jHoBHcC8wyCCjHYFP1TOGz+IonM=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3r080+3Znw90Om2KuU0scFpfxPNzk//v+1w//XsTsY/Dw 1ly4tCOWhUGQiUFWTJHlyzaeo/srDil6GdqehpnDygQyhIGLUwAm8i6EYZ5OjefHFZHahfUC1ff+mC QvEGHv/cqwYF5lq9OPT3/tU0UnLsqcfuM3V8EhUQA= 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?1756734694495846100?= X-GMAIL-MSGID: =?utf-8?q?1756734694495846100?= 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: Linus Walleij Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Linus Walleij --- drivers/usb/fotg210/fotg210-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c index 51ac93a2eb98..1c5eb8f8c19c 100644 --- a/drivers/usb/fotg210/fotg210-hcd.c +++ b/drivers/usb/fotg210/fotg210-hcd.c @@ -862,7 +862,7 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210) { struct usb_bus *bus = &fotg210_to_hcd(fotg210)->self; - debugfs_remove(debugfs_lookup(bus->bus_name, fotg210_debug_root)); + debugfs_lookup_and_remove(bus->bus_name, fotg210_debug_root); } /* handshake - spin reading hc until handshake completes or fails