Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=968... Commit: 968f58cbdf01f6e8f3b7f3024556b5d7d5237b88 Parent: 6f8a9a9e4ccc96a3383ea8de181b9224e0907802 Author: Andrew Price anprice@redhat.com AuthorDate: Fri Jan 20 11:07:45 2012 +0000 Committer: Andrew Price anprice@redhat.com CommitterDate: Fri Jan 20 11:07:45 2012 +0000
fsck.gfs2: Plug a leak in peruse_system_dinode()
Spotted by coverity: Variable "ip" going out of scope leaks the storage it points to.
If one of the if/else conditions is true, ip is stored in a global variable or freed, so the leak happens when none of them are true. To fix this I've added an else statement to free ip and moved the out_discard_ip label into it to avoid duplicating the inode_put().
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/fsck/initialize.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 3daf12d..f07e0b2 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -911,11 +911,10 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di, fix_md.qinode = ip; log_warn(_("Found system quota file at: 0x%llx\n"), di->di_num.no_addr); - } - return; - + } else { out_discard_ip: - inode_put(&ip); + inode_put(&ip); + } }
/**
cluster-commits@lists.fedorahosted.org