From patchwork Thu Feb 2 15:12:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 51992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp298906wrn; Thu, 2 Feb 2023 07:19:26 -0800 (PST) X-Google-Smtp-Source: AK7set8cwgNaI4oS4CkKmD30BNek4bqEWPXrjex6Ma149dXthElf6fWZ+cbIh/s1wXjITU7HHLlL X-Received: by 2002:a05:6402:4012:b0:4a2:46f3:467e with SMTP id d18-20020a056402401200b004a246f3467emr7063441eda.30.1675351166177; Thu, 02 Feb 2023 07:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675351166; cv=none; d=google.com; s=arc-20160816; b=EepNGteM1dPPh42nwUcxxapibuwzm/zus8zUlDWO5+zqmWXYz6xHj/M4LTozn02wUN IYvWAX9pUZs4ML/god3lvhVw+M43UNIt+Yc6sYBxaG+Ty/vCsOrMuODrnDPEKemNBn5l JKqrI960EbEhX+weNIRi4cb1BKUDPRLxoGlBGZq4O56Mr3xYM34lkdYaLIE9BtYHsNqv O8Y98IuoYNhZce6iB+Qtrr3WOx++/h8VRBPBj62SxWVX4bp+ALnwQqEvpF3aVqcsPXoJ KIoVHLwNDdWA1o0/4/NEUobAhkzoxkzfxHMYk22BxZnCqb28WTd8vbaB6ap3aW3mbBQS tfwg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Trhgb1pQAJs5Tx8iD3YLN3oR/4OQctA3lCN3xgzuYww=; b=dbr1k78niqhFMdVk+K5SBWIKcI23VI1xpULGJHuvLuuXDy8B/D31wmpE0/UwFhwhi7 cTbGlSJ7jcyVcUZMTXOASN+8Klb6ADuIy6d6auBEVewEIicBsA6CBhuyyc4yjnNtxfyn xO+BnTctI2uNOlHay/l8oatR1GZEFB9/RW03YCU3OZtzZHsxnwzleaLZgHMVPO9FPxsQ LuBd5eH+UP5qJiCtwrpyPL8CYu++S5YOYdrcBr1W6mdv1q0rNFgY+ztd116hvtlb5ONY fE3L15TGfaOA6+CXrGwd/mFYhudn43MHGhScWKJsYhY/FfhaJcPDrNH7NoRcQnkvvpJ6 jm/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XxumIkuC; 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 d23-20020aa7d5d7000000b004a0b0e8a994si11630309eds.511.2023.02.02.07.19.01; Thu, 02 Feb 2023 07:19:26 -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=XxumIkuC; 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 S231644AbjBBPM4 (ORCPT + 99 others); Thu, 2 Feb 2023 10:12:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbjBBPMy (ORCPT ); Thu, 2 Feb 2023 10:12:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F738945D6 for ; Thu, 2 Feb 2023 07:12:28 -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 8B58D61BC5 for ; Thu, 2 Feb 2023 15:12:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CC70C433D2; Thu, 2 Feb 2023 15:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675350739; bh=RxwsXdM5vF3QKbjv+va1tNRqLPUWeljily2y8yLNGOo=; h=From:To:Cc:Subject:Date:From; b=XxumIkuCc2EZQtiPTNUlcP8o/DgVsbV+UzZXRLKqsR70Dx5F6dWknhct4v8PGSERh 3Sd1uorAhu5dTJv7LUI+ba4Q7mMT1JtCpH5fMTmneKhikdXhkxqdwvu88yu/Rwsftf mSlDfbEjRghmjhFrx4rr19E/ErS9disUDmGK02yM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH] kernel/time/test_udelay.c: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 16:12:14 +0100 Message-Id: <20230202151214.2306822-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=863; i=gregkh@linuxfoundation.org; h=from:subject; bh=RxwsXdM5vF3QKbjv+va1tNRqLPUWeljily2y8yLNGOo=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3L50yYwrXs1PIlzNsn/63MZnp79Put7ffFqz7x9MnFmie M02zI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACai8pRhrqj+6v7U6nylqZ9PxfrnWC Tq3lrVyzA/6OCUPbu5vT89VHyla/o+Lf4N1/aXAA== 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?1756733024250456345?= X-GMAIL-MSGID: =?utf-8?q?1756733024250456345?= 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. Signed-off-by: Greg Kroah-Hartman --- kernel/time/test_udelay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/test_udelay.c b/kernel/time/test_udelay.c index 13b11eb62685..20d5df631570 100644 --- a/kernel/time/test_udelay.c +++ b/kernel/time/test_udelay.c @@ -149,7 +149,7 @@ module_init(udelay_test_init); static void __exit udelay_test_exit(void) { mutex_lock(&udelay_test_lock); - debugfs_remove(debugfs_lookup(DEBUGFS_FILENAME, NULL)); + debugfs_lookup_and_remove(DEBUGFS_FILENAME, NULL); mutex_unlock(&udelay_test_lock); }