]> git.itanic.dy.fi Git - linux-stable/commit
debugfs: add debugfs_lookup_and_remove()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Sep 2022 14:59:15 +0000 (16:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 10:04:54 +0000 (12:04 +0200)
commit9fc8c5fa423052e9b5c19939edbad7faf547bc59
treed5bfcb6b8ab4c14d88a46bf2d8c72a48975ed092
parent0d895d2bb120438a982c39e20da43c97ec62c953
debugfs: add debugfs_lookup_and_remove()

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>
fs/debugfs/inode.c
include/linux/debugfs.h