Skip to contentSkip to conversation

vfs: fix reference leak in d_prune_aliases()

PATCH In review Yan, Zheng 2 participants 2 messages Nov 19, 2014 VFS

lore
Share & tools
lore

Yan, Zheng

author
#0 lore raw

PATCH 1/1 vfs: fix reference leak in d_prune_aliases()

---
 fs/dcache.c | 1 +
 1 file changed, 1 insertion(+)
fs/dcache.c +1 -0
index 3ffef7f..5bc72b0 100644
@@ -778,6 +778,7 @@ restart:
 			struct dentry *parent = lock_parent(dentry);
 			if (likely(!dentry->d_lockref.count)) {
 				__dentry_kill(dentry);
+				dput(parent);
 				goto restart;
 			}
 			if (parent)
Signature · 1 line
1.9.3
maintainer
#1 lore raw
Quoted 10 lines · Zheng
---
 fs/dcache.c | 1 +
 1 file changed, 1 insertion(+)
fs/dcache.c +0 -0
index 3ffef7f..5bc72b0 100644

fs/dcache.c restart: · line 784

Quoted 7 lines
fs/dcache.c +1 -0
@@ -778,6 +778,7 @@ restart:
 			struct dentry *parent = lock_parent(dentry);
 			if (likely(!dentry->d_lockref.count)) {
 				__dentry_kill(dentry);
+				dput(parent);
 				goto restart;
 			}
 			if (parent)

Good catch... Applied, will push to Linus. I'm putting the following as commit message:

In "d_prune_alias(): just lock the parent and call __dentry_kill()" the old dget + d_drop + dput has been replaced with lock_parent + __dentry_kill; unfortunately, dput() does more than just killing dentry - it also drops the reference to parent. New variant leaks that reference and needs dput(parent) after killing the child off.

Is the above OK with you?