gfs2: Fix memory leak of object lsi on error return path
authorColin Ian King <colin.king@canonical.com>
Mon, 12 Jul 2021 16:24:30 +0000 (17:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:50:32 +0000 (09:50 +0200)
commitc4aaad8a338958016d4a0633564ec1c15341efea
tree5679ac3f347ae3020c2ea89c4d4d1d9978d41e77
parent8c3b5028ec02924f3b037a6d07124a006a9a3c4f
gfs2: Fix memory leak of object lsi on error return path

[ Upstream commit a6579cbfd7216b071008db13360c322a6b21400b ]

In the case where IS_ERR(lsi->si_sc_inode) is true the error exit path
to free_local does not kfree the allocated object lsi leading to a memory
leak. Fix this by kfree'ing lst before taking the error exit path.

Addresses-Coverity: ("Resource leak")
Fixes: 97fd734ba17e ("gfs2: lookup local statfs inodes prior to journal recovery")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/gfs2/ops_fstype.c