]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
configfs: fix config_item refcnt leak in configfs_rmdir()
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Sat, 25 Apr 2020 12:52:26 +0000 (20:52 +0800)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Mon, 22 Jun 2020 20:22:27 +0000 (17:22 -0300)
commit8cd91d3b2a58bc0878450fef6a93b739aa804bcd
tree81dfe8abbf05784e0d3d0a5dee7bf928edca1630
parent736ae67c1cad1f8398a5570dbf17ea5795ac1f7d
configfs: fix config_item refcnt leak in configfs_rmdir()

BugLink: https://bugs.launchpad.net/bugs/1881178
[ Upstream commit 8aebfffacfa379ba400da573a5bf9e49634e38cb ]

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 <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/configfs/dir.c