Commit 1084e88a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Jialin Zhang
Browse files

debugfs: add debugfs_lookup_and_remove()

stable inclusion
from stable-v5.10.143
commit 68f22c80c18186f3dba9b2b60bd05488987ae7ce
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0U6

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=68f22c80c18186f3dba9b2b60bd05488987ae7ce



--------------------------------

commit dec9b2f1 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: default avatarKuyo Chang <kuyo.chang@mediatek.com>
Tested-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
Link: https://lore.kernel.org/r/YxIaQ8cSinDR881k@kroah.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 21c850c7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment