From patchwork Thu Feb 2 14:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 51949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264799wrn; Thu, 2 Feb 2023 06:18:55 -0800 (PST) X-Google-Smtp-Source: AK7set+b2RStV/ji4EegbKm6Bc68AeecB14SBJfoY2FiNJ/0rb6o7IzzEHBf76jmSQlcXGeF+sDR X-Received: by 2002:a17:902:e1d5:b0:193:2d53:3fcf with SMTP id t21-20020a170902e1d500b001932d533fcfmr5480709pla.14.1675347535373; Thu, 02 Feb 2023 06:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675347535; cv=none; d=google.com; s=arc-20160816; b=QhV2YrTpMfLiS7tiNv7JsRsWO5wAa20gEu/V3YRwa4h9Ta3kmAkOqcSpr3jSiLOrOP 93O/WpfKIW17osWCyCzqJYnC6Btd5/yBjPv8z7HPcINqqp6WvQnOOsOqdUn4IT848nJE x+o/NUKMhNlyXzKn+P/pxQAyxCJq4PyapaBLeq3y2kANjLom0agh1QdJ/K0B6lHYdkJN DOsZ3zly+tSkHFl4r4dGq2YEzKuR33tnKNYOAOhthpbHTIX7stdGgH2v5b4T6IK6h2b4 1SUHJ+jrvTlu9/VZxkiWSUaJ1jj+OC2uzz+dQd385lgSFl/HVBphyrQyZGtDW24jcrap AGcA== 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=9d24kjexJeIYP2Z3FNOAJ6syM9of47ZhqGeZjTXQyAY=; b=Zng6ABRFTTvMM7LN3x7qTg6YQlSGC0NbOGsvfdU8SXqR7EfWHc1/m/J28OPWqMCq86 E/0enNWQNVIhMy72NEwz/p8bbVlZ59P/tZlzqLHJx8GCEWZYM8iLg/OvQ5S4pvYRHKis pG107jYvadyTN28pdYTjJdNSfoQ81peghbKG+7goZ5Yz4VtZpJ2/J5gJGJ0nshV8Z8zV k62G38r5U3essMkae3mKuo1x1GiK3uj9qm/wxPKb5zfWMJc0xkMrr77cNYJvvXNXXnLg NkRouf2DEC1kiTPnuXpKaVkIcu20DJxBHmlvxgi9dZ0tnjq2pkepLV2QMdfkRIwfJlDW Kssg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kZ8Fyyzj; 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 bd5-20020a170902830500b00198d2026752si255480plb.444.2023.02.02.06.18.40; Thu, 02 Feb 2023 06:18:55 -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=kZ8Fyyzj; 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 S232152AbjBBOQ2 (ORCPT + 99 others); Thu, 2 Feb 2023 09:16:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjBBOQ1 (ORCPT ); Thu, 2 Feb 2023 09:16:27 -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 55CC2E3A7 for ; Thu, 2 Feb 2023 06:16:26 -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 E43F261B6F for ; Thu, 2 Feb 2023 14:16:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBC62C433D2; Thu, 2 Feb 2023 14:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675347385; bh=eyB9EfdjOjsyCAKlInNRW2YVGbe2pIAJQIW53I+B88U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZ8Fyyzj2OGN8S6mWaEhgew/LAVLGgvjnQ61ib9VFFV/gVbcZQGHjpF/qgI7FkFtn qIE9lrTm0ba4djaeXR/0Esl1E/sqI5pFo5AuI448Qsna9gV5XR/1QTWklKoVd6dvT1 rG5sK2Rn4OXinNEYf+lp0ii4InhfUGm3ZpFUC2+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH 2/2] drivers: base: dd: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:16:21 +0100 Message-Id: <20230202141621.2296458-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202141621.2296458-1-gregkh@linuxfoundation.org> References: <20230202141621.2296458-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=896; i=gregkh@linuxfoundation.org; h=from:subject; bh=eyB9EfdjOjsyCAKlInNRW2YVGbe2pIAJQIW53I+B88U=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3j2797s/7R1V/UnRt1zTVWLXqFAmvM4+ftDYevrLuhU/p ThXHjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZhI7nSGBcfe8F/waeIRTZx7wu2LZd V0BfdPjQzziy7V/7+8VuHxxxWPKq/+mTj91TGuDAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756729216877770397?= X-GMAIL-MSGID: =?utf-8?q?1756729216877770397?= 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: "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 817ef27a78f7..8def2ba08a82 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -370,7 +370,7 @@ late_initcall(deferred_probe_initcall); static void __exit deferred_probe_exit(void) { - debugfs_remove_recursive(debugfs_lookup("devices_deferred", NULL)); + debugfs_lookup_and_remove("devices_deferred", NULL); } __exitcall(deferred_probe_exit);