gfs2-utils: master - gfs2_convert: Fix potential memory leaks in adjust_inode
Andrew Price
andyp at fedoraproject.org
Fri Sep 19 13:44:48 UTC 2014
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=137f1730280d8ac02999eb64e0629763252386eb
Commit: 137f1730280d8ac02999eb64e0629763252386eb
Parent: fb30e395e6e8a05246f37365f141bef22b73193e
Author: Andrew Price <anprice at redhat.com>
AuthorDate: Thu Sep 18 14:07:32 2014 +0100
Committer: Andrew Price <anprice at redhat.com>
CommitterDate: Thu Sep 18 14:07:32 2014 +0100
gfs2_convert: Fix potential memory leaks in adjust_inode
Spotted by coverity: Variable "inode" going out of scope leaks the
storage it points to.
Signed-off-by: Andrew Price <anprice at redhat.com>
---
gfs2/convert/gfs2_convert.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 19a9839..16ec150 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -877,7 +877,7 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
if (!fixdir) {
/*FIXME: Same message as fix_cdpn_symlink */
log_crit(_("Error: out of memory.\n"));
- return -1;
+ goto err_freei;
}
memset(fixdir, 0, sizeof(struct inode_block));
fixdir->di_addr = inode->i_di.di_num.no_addr;
@@ -931,18 +931,18 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
inode->i_di.di_generation = 0;
if (adjust_indirect_blocks(sbp, inode))
- return -1;
+ goto err_freei;
/* Check for cdpns */
if (S_ISLNK(inode->i_di.di_mode)) {
ret = fix_cdpn_symlink(sbp, bh, inode);
if (ret)
- return -1;
+ goto err_freei;
}
/* Check for extended attributes */
if (inode->i_di.di_eattr) {
ret = fix_xattr(sbp, bh, inode);
if (ret)
- return -1;
+ goto err_freei;
}
}
@@ -950,6 +950,9 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
inode_put(&inode); /* does gfs2_dinode_out if modified */
sbp->md.next_inum++; /* update inode count */
return 0;
+err_freei:
+ inode_put(&inode);
+ return -1;
} /* adjust_inode */
static int next_rg_meta(struct rgrp_tree *rgd, uint64_t *block, int first)
More information about the cluster-commits
mailing list