Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   gfs2_edit: Fix memory leaks (http://www.linux-archive.org/cluster-development/623213-gfs2_edit-fix-memory-leaks.html)

01-20-2012 02:10 PM

gfs2_edit: Fix memory leaks
 
From: Bob Peterson <rpeterso@redhat.com>

This patch plugs a couple memory leaks found by valgrind.

rhbz#675723
---
gfs2/edit/savemeta.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 33f2970..1b9d0a8 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -132,6 +132,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
*gstruct_len = sizeof(struct gfs2_dinode);
else
*gstruct_len = sbd.bsize;
+ inode_put(&inode);
break;
case GFS2_METATYPE_IN: /* 5 (indir inode blklst) */
*gstruct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
@@ -490,7 +491,10 @@ static void save_inode_data(struct metafd *mfd)
mybh = osi_list_entry(cur_list->next,
struct gfs2_buffer_head,
b_altlist);
- osi_list_del(&mybh->b_altlist);
+ if (mybh == inode->i_bh)
+ osi_list_del(&mybh->b_altlist);
+ else
+ brelse(mybh);
}
}
/* Process directory exhash inodes */
@@ -808,6 +812,8 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
free(savedata);
savemetaclose(&mfd);
close(sbd.device_fd);
+ free(indirect);
+ gfs2_rgrp_free(&sbd.rgtree);
exit(0);
}

@@ -1032,6 +1038,6 @@ void restoremeta(const char *in_fn, const char *out_device,
gzclose(gzfd);
if (!printblocksonly)
close(sbd.device_fd);
-
+ free(indirect);
exit(error);
}
--
1.7.7.5


All times are GMT. The time now is 12:21 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.