]> git.baikalelectronics.ru Git - 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)
committerChristoph Hellwig <hch@lst.de>
Mon, 27 Apr 2020 06:17:10 +0000 (08:17 +0200)
commit1fcb9753c8a7814b74a574c5eb2f71aacfb9b4b9
tree81791bfd6bc7b1cb22edd31de2e6ea7ea2234506
parent955ac135a3b8737477606412c5bb1c4a86e4f4bf
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 <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/configfs/dir.c