From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Price Date: Fri, 20 Jan 2012 12:39:26 +0000 Subject: [Cluster-devel] [PATCH 2/3] fsck.gfs2: Plug a leak in peruse_system_dinode() In-Reply-To: <1327063167-10291-1-git-send-email-anprice@redhat.com> References: <1327063167-10291-1-git-send-email-anprice@redhat.com> Message-ID: <1327063167-10291-2-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- 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); + } } /** -- 1.7.7.5