From patchwork Thu Feb 2 14:09:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 51940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp261327wrn; Thu, 2 Feb 2023 06:13:21 -0800 (PST) X-Google-Smtp-Source: AK7set+N3luwkpt3gFqgHZ69CvRNxiKqjfzRLauPmEf99AfO5j2/sfyNdbdK7d8VE7ru6FXmHCtY X-Received: by 2002:aa7:da04:0:b0:4a0:e0ad:8d3b with SMTP id r4-20020aa7da04000000b004a0e0ad8d3bmr5857692eds.3.1675347201420; Thu, 02 Feb 2023 06:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675347201; cv=none; d=google.com; s=arc-20160816; b=iAI7qYDsn3a2xxkhNOL47PsMC+Vl6H7ss0G1FyZtrPF2NtfJ0CDWizQn0awFBUwQhN toU1HMmQPtOkXYLzVEET9TrGbH0JZ1mY/ZOntIb2cN32SrtyPn9lGbPzwvxrzWv2UO9Y +6iMYWQXge3Kxvc6DwWclEUOhnLZvU2c8CM2OeqiOYsAPIvtI2bT+HwWF2tDwHNbEuTU BRfQCM4G+pF0lc9RJm3Q3qIkYo3js/OTk/9NbgWe1DvoNzwOdhkaieQ50Gdr3DWxjHA9 UMAN96WwxzjyFK7Fow7qpQkmgrg/l547olobQ4R+MR0/hMsUtJkJ4WdfO+7Y++B/Gznq GO2Q== 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=TYTPZJBTw2pih3sPV4nP45+kYQ1xmxgvGHs+MoZyORg=; b=ugVZILo9siMQS2AUt6BsGDWE1rVvHepip40QpR63CkMI7vpFqhXo0xoCoLEIqDMJ/k mANE2tfOjF9QPJpoIILPangz9zfoHrG4VBYBpNDXmIqKZCvFf6RnVORO9uHLoGZ38FJT laWXNzw1Zfi76UmL3uEhFMx87XFOgKBcu9Qa71IyCrhP7pSlx/Fs/wRAO9QLfD9Vjum3 MOcQUfqVGrModaCBU7NcbK+vsjOGOiTYzYj5H5QtsxmR8FYNPjoVTkCZIK+h7kOynumu 3qMoQ7k3HP0wNtAV9Lufmp4SeuDviavAHa9uf9455VsqE5LbArP2ZH57xoN89RLUdnJt ERcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qkCf7n/j"; 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 q8-20020a056402248800b0049e1b840be0si27484293eda.9.2023.02.02.06.12.57; Thu, 02 Feb 2023 06:13:21 -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="qkCf7n/j"; 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 S231761AbjBBOJ2 (ORCPT + 99 others); Thu, 2 Feb 2023 09:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBBOJ0 (ORCPT ); Thu, 2 Feb 2023 09:09:26 -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 57BD087161; Thu, 2 Feb 2023 06:09:24 -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 467DD61B66; Thu, 2 Feb 2023 14:09:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F10DCC4339B; Thu, 2 Feb 2023 14:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675346962; bh=fcXByrYMeAYU0QEawUizJluIVGp45lsSXGtpusnK5H4=; h=From:To:Cc:Subject:Date:From; b=qkCf7n/jq3U7En6Zb8foWGxOWszxPIiv35R1TFMs5MQfNxsXsR8aGMXrHMEW3sTIg e2DlqdnjIcGct5PnHihqUIUrI5quCDkkE5KkIxWOCxiezGsKZqmABHg/zOY8vfEMhU RJpXWxYqKYD77OH9VGce4I3KSri2GhRh65I7N3e4= From: Greg Kroah-Hartman To: linux-hyperv@vger.kernel.org Cc: Greg Kroah-Hartman , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , linux-kernel@vger.kernel.org Subject: [PATCH] HV: hv_balloon: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:09:18 +0100 Message-Id: <20230202140918.2289522-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=1073; i=gregkh@linuxfoundation.org; h=from:subject; bh=fcXByrYMeAYU0QEawUizJluIVGp45lsSXGtpusnK5H4=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3j/AwXnp9/q2R/p2bsi98QiwnsJbMM3LXV2q6Os2K48yE Lhe9jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiI/DWG+c6+Ni+rf1i6Lt3SfUxbdn NtwrGCKQzzs6MYGWq1bO/NY7mpek/urOjVZW3CAA== 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?1756728866856426039?= X-GMAIL-MSGID: =?utf-8?q?1756728866856426039?= 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: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Wei Liu Cc: Dexuan Cui Cc: linux-hyperv@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Michael Kelley --- drivers/hv/hv_balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index cbe43e2567a7..64ac5bdee3a6 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -1963,7 +1963,7 @@ static void hv_balloon_debugfs_init(struct hv_dynmem_device *b) static void hv_balloon_debugfs_exit(struct hv_dynmem_device *b) { - debugfs_remove(debugfs_lookup("hv-balloon", NULL)); + debugfs_lookup_and_remove("hv-balloon", NULL); } #else