]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
debugfs: add debugfs_lookup_and_remove()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Sep 2022 14:59:15 +0000 (16:59 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 23 Nov 2022 14:11:07 +0000 (15:11 +0100)
commit72f62523119e669938553d4c6fdfeff7c8800654
treea3c85d99cc5b519e95ff009e432e08f79fbb1c09
parent426c5c24131c4a9375736bf123674b827d648abb
debugfs: add debugfs_lookup_and_remove()

BugLink: https://bugs.launchpad.net/bugs/1993003
commit dec9b2f1e0455a151a7293c367da22ab973f713e upstream.

There is a very common pattern of using
debugfs_remove(debufs_lookup(..)) which results in a dentry leak of the
dentry that was looked up.  Instead of having to open-code the correct
pattern of calling dput() on the dentry, create
debugfs_lookup_and_remove() to handle this pattern automatically and
properly without any memory leaks.

Cc: stable <stable@kernel.org>
Reported-by: Kuyo Chang <kuyo.chang@mediatek.com>
Tested-by: Kuyo Chang <kuyo.chang@mediatek.com>
Link: https://lore.kernel.org/r/YxIaQ8cSinDR881k@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/debugfs/inode.c
include/linux/debugfs.h