pds_core: fix debugfs_lookup dentry leak and error handling
Subsystems (3)
PATCH 1/1 pds_core: fix debugfs_lookup dentry leak and error handling
debugfs_lookup() returns a dentry with an elevated reference count that must be released with dput(). The current code discards the returned dentry without calling dput(), causing a reference leak on every firmware reset recovery.
Additionally, when CONFIG_DEBUG_FS is disabled, debugfs_lookup() returns ERR_PTR(-ENODEV), not NULL. The current check passes for error pointers and would call dput() on an invalid pointer, causing a crash.
--- drivers/net/ethernet/amd/pds_core/debugfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/pds_core/debugfs.c +6 -1
@@ -64,9 +64,14 @@ DEFINE_SHOW_ATTRIBUTE(identity);void pdsc_debugfs_add_ident (struct pdsc *pdsc) { +struct dentry *dentry; +/* This file will already exist in the reset flow */ -if (debugfs_lookup ("identity" , pdsc->dentry)) + dentry =debugfs_lookup ("identity" , pdsc->dentry); +if (!IS_ERR_OR_NULL (dentry)) { +dput (dentry);return ; + }debugfs_create_file ("identity" ,0400 , pdsc->dentry, pdsc, &identity_fops);
Signature · 1 line
2.43.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 15 May 2026 21:29:07 +0000 you wrote:
debugfs_lookup()returns a dentry with an elevated reference count that must be released withdput(). The current code discards the returned dentry without callingdput(), causing a reference leak on every firmware reset recovery.Additionally, when
CONFIG_DEBUG_FSis disabled,debugfs_lookup()returnsERR_PTR(-ENODEV), not NULL. The current check passes for error pointers and would calldput()on an invalid pointer, causing a crash.[...]
Here is the summary with links:
- [net] pds_core: fix debugfs_lookup dentry leak and error handling
https://git.kernel.org/netdev/net/c/dc416e32baae
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html