cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/3] fsck.gfs2: Plug a leak in peruse_system_dinode()
Date: Fri, 20 Jan 2012 12:39:26 +0000	[thread overview]
Message-ID: <1327063167-10291-2-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1327063167-10291-1-git-send-email-anprice@redhat.com>

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);
+	}
 }
 
 /**
-- 
1.7.7.5



  reply	other threads:[~2012-01-20 12:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20 12:39 [Cluster-devel] [PATCH 1/3] libgfscontrol: Fix resource leaks Andrew Price
2012-01-20 12:39 ` Andrew Price [this message]
2012-01-20 12:39 ` [Cluster-devel] [PATCH 3/3] fsck.gfs2: Fix unchecked malloc in gfs2_dup_set() Andrew Price
2012-01-20 13:40   ` Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327063167-10291-2-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).