Skip to content

Commit 8aebfff

Browse files
sherllyChristoph Hellwig
authored andcommitted
configfs: fix config_item refcnt leak in configfs_rmdir()
configfs_rmdir() invokes configfs_get_config_item(), which returns a reference of the specified config_item object to "parent_item" with increased refcnt. When configfs_rmdir() returns, local variable "parent_item" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in one exception handling path of configfs_rmdir(). When down_write_killable() fails, the function forgets to decrease the refcnt increased by configfs_get_config_item(), causing a refcnt leak. Fix this issue by calling config_item_put() when down_write_killable() fails. Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 6a8b55e commit 8aebfff

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/configfs/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
15191519
spin_lock(&configfs_dirent_lock);
15201520
configfs_detach_rollback(dentry);
15211521
spin_unlock(&configfs_dirent_lock);
1522+
config_item_put(parent_item);
15221523
return -EINTR;
15231524
}
15241525
frag->frag_dead = true;

0 commit comments

Comments
 (0)