linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yang Yingliang <yangyingliang@huawei.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.10 25/30] kernel/fail_function: fix memory leak with using debugfs_lookup()
Date: Fri,  3 Mar 2023 16:47:10 -0500	[thread overview]
Message-ID: <20230303214715.1452256-25-sashal@kernel.org> (raw)
In-Reply-To: <20230303214715.1452256-1-sashal@kernel.org>

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

[ Upstream commit 2bb3669f576559db273efe49e0e69f82450efbca ]

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: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20230202151633.2310897-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/fail_function.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index b0b1ad93fa957..8f3795d8ac5b0 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -163,10 +163,7 @@ static void fei_debugfs_add_attr(struct fei_attr *attr)
 
 static void fei_debugfs_remove_attr(struct fei_attr *attr)
 {
-	struct dentry *dir;
-
-	dir = debugfs_lookup(attr->kp.symbol_name, fei_debugfs_dir);
-	debugfs_remove_recursive(dir);
+	debugfs_lookup_and_remove(attr->kp.symbol_name, fei_debugfs_dir);
 }
 
 static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)
-- 
2.39.2


  parent reply	other threads:[~2023-03-03 21:58 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 21:46 [PATCH AUTOSEL 5.10 01/30] IB/hfi1: Update RMT size calculation Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 02/30] iommu/amd: Fix error handling for pdev_pri_ats_enable() Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 03/30] media: uvcvideo: Handle cameras with invalid descriptors Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 04/30] media: uvcvideo: Handle errors from calls to usb_string Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 05/30] media: uvcvideo: Quirk for autosuspend in Logitech B910 and C910 Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 06/30] media: uvcvideo: Silence memcpy() run-time false positive warnings Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 07/30] staging: emxx_udc: Add checks for dma_alloc_coherent() Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 08/30] tty: fix out-of-bounds access in tty_driver_lookup_tty() Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 09/30] tty: serial: fsl_lpuart: disable the CTS when send break signal Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 10/30] serial: sc16is7xx: setup GPIO controller later in probe Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 11/30] mei: bus-fixup:upon error print return values of send and receive Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 12/30] parport_pc: Set up mode and ECR masks for Oxford Semiconductor devices Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 13/30] tools/iio/iio_utils:fix memory leak Sasha Levin
2023-03-03 21:46 ` [PATCH AUTOSEL 5.10 14/30] iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_status_word() Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 15/30] iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_config_word() Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 16/30] firmware: coreboot: framebuffer: Ignore reserved pixel color bits Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 17/30] PCI: loongson: Prevent LS7A MRRS increases Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 18/30] usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 19/30] USB: ene_usb6250: Allocate enough memory for full object Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 20/30] usb: uvc: Enumerate valid values for color matching Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 21/30] usb: gadget: uvc: Make bSourceID read/write Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 22/30] PCI: Align extra resources for hotplug bridges properly Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 23/30] PCI: Take other bus devices into account when distributing resources Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 24/30] kernel/power/energy_model.c: fix memory leak with using debugfs_lookup() Sasha Levin
2023-03-03 21:47 ` Sasha Levin [this message]
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 26/30] PCI: loongson: Add more devices that need MRRS quirk Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 27/30] PCI: Add ACS quirk for Wangxun NICs Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 28/30] phy: rockchip-typec: Fix unsigned comparison with less than zero Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 29/30] soundwire: cadence: Remove wasted space in response_buf Sasha Levin
2023-03-03 21:47 ` [PATCH AUTOSEL 5.10 30/30] soundwire: cadence: Drain the RX FIFO after an IO timeout Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230303214715.1452256-25-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yangyingliang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).