From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/5] fsck.gfs2: Fix memory leaks in pass1_process_rgrp
Date: Mon, 23 Feb 2015 18:43:22 +0000 [thread overview]
Message-ID: <1424717006-20839-1-git-send-email-anprice@redhat.com> (raw)
Spotted by coverity: "Variable ibuf going out of scope leaks the storage
it points to"
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/fsck/pass1.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index b516a21..69c88f4 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1625,7 +1625,10 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
unsigned k, n, i;
uint64_t *ibuf = malloc(sdp->bsize * GFS2_NBBY * sizeof(uint64_t));
- int ret;
+ int ret = 0;
+
+ if (ibuf == NULL)
+ return FSCK_ERROR;
for (k = 0; k < rgd->ri.ri_length; k++) {
n = lgfs2_bm_scan(rgd, k, ibuf, GFS2_BLKST_DINODE);
@@ -1633,11 +1636,11 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
if (n) {
ret = pass1_process_bitmap(sdp, rgd, ibuf, n);
if (ret)
- return ret;
+ goto out;
}
if (fsck_abort)
- return 0;
+ goto out;
/*
For GFS1, we have to count the "free meta" blocks in the
resource group and mark them specially so we can count them
@@ -1650,12 +1653,13 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
for (i = 0; i < n; i++) {
gfs2_blockmap_set(bl, ibuf[i], GFS2_BLKST_UNLINKED);
if (fsck_abort)
- return 0;
+ goto out;
}
}
+out:
free(ibuf);
- return 0;
+ return ret;
}
/**
--
1.9.3
next reply other threads:[~2015-02-23 18:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-23 18:43 Andrew Price [this message]
2015-02-23 18:43 ` [Cluster-devel] [PATCH 2/5] libgfs2: Use the correct parent for rgrp tree insertion Andrew Price
2015-02-23 18:43 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove some obsolete function declarations Andrew Price
2015-02-23 18:43 ` [Cluster-devel] [PATCH 4/5] gfs2-utils: Move metafs handling into gfs2/mkfs/ Andrew Price
2015-02-23 18:43 ` [Cluster-devel] [PATCH 5/5] gfs2_grow/jadd: Use a matching context mount option in mount_gfs2_meta Andrew Price
2015-02-23 19:17 ` [Cluster-devel] [PATCH 1/5] fsck.gfs2: Fix memory leaks in pass1_process_rgrp Bob Peterson
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=1424717006-20839-1-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).