Skip to content

Commit

Permalink
gfs2: Fix memory leak of object lsi on error return path
Browse files Browse the repository at this point in the history
[ Upstream commit a6579cb ]

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: 97fd734 ("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>
  • Loading branch information
Colin Ian King authored and gregkh committed Sep 15, 2021
1 parent 8c3b502 commit c4aaad8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/gfs2/ops_fstype.c
Expand Up @@ -660,6 +660,7 @@ static int init_statfs(struct gfs2_sbd *sdp)
error = PTR_ERR(lsi->si_sc_inode);
fs_err(sdp, "can't find local \"sc\" file#%u: %d\n",
jd->jd_jid, error);
kfree(lsi);
goto free_local;
}
lsi->si_jid = jd->jd_jid;
Expand Down

0 comments on commit c4aaad8

Please sign in to comment.