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 <[email protected]>
---
 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

Reply via email to