From fceb0d99809a824cc4a4e7cbfad8f3a187169f83 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Tue, 3 Feb 2004 04:26:51 +0000 Subject: [PATCH] Fix a few more leaks in libxfs/xfs_repair doc changes --- doc/CHANGES | 3 +++ libxfs/init.c | 9 ++++++++- repair/dir2.c | 1 + repair/io.c | 25 ------------------------- repair/protos.h | 2 -- repair/sb.c | 25 ------------------------- 6 files changed, 12 insertions(+), 53 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index d6b4376e9..8c9fed651 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,6 @@ +cvs + - Fix a few more libxfs/repair leaks + xfsprogs-2.6.3 (19 January 2003) - Merge Steve Langasek's work on the Debian installer support for xfsprogs. diff --git a/libxfs/init.c b/libxfs/init.c index c26377c98..075775f58 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -705,5 +705,12 @@ void libxfs_umount(xfs_mount_t *mp) { manage_zones(1); - free(mp->m_perag); + if (mp->m_perag) { + int agno; + for (agno = 0; agno < mp->m_maxagi; agno++) { + if (mp->m_perag[agno].pagb_list) + free(mp->m_perag[agno].pagb_list); + } + free(mp->m_perag); + } } diff --git a/repair/dir2.c b/repair/dir2.c index b2629d9e2..8f878284c 100644 --- a/repair/dir2.c +++ b/repair/dir2.c @@ -142,6 +142,7 @@ da_read_buf( XFS_BUF_COUNT(bp)); } } + free(bplist); return dabuf; failed: for (i = 0; i < nex; i++) diff --git a/repair/io.c b/repair/io.c index 2adb4578b..d5f2bbc65 100644 --- a/repair/io.c +++ b/repair/io.c @@ -39,8 +39,6 @@ void io_init(void) { - int i; - /* open up filesystem device */ ASSERT(fs_name != NULL && *fs_name != '\0'); @@ -48,27 +46,4 @@ io_init(void) if ((fs_fd = open (fs_name, (no_modify? O_RDONLY : O_RDWR))) < 0) { do_error(_("couldn't open filesystem \"%s\"\n"), fs_name); } - - /* initialize i/o buffers */ - - iobuf_size = 1000 * 1024; - smallbuf_size = 4 * 4096; /* enough for an ag */ - - /* - * sbbuf_size must be < XFS_MIN_AG_BLOCKS (64) * smallest block size, - * otherwise you might get an EOF when reading in the sb/agf from - * the last ag if that ag is small - */ - sbbuf_size = 2 * 4096; /* 2 * max sector size */ - - if ((iobuf = malloc(iobuf_size)) == NULL) - do_error(_("couldn't malloc io buffer\n")); - - if ((smallbuf = malloc(smallbuf_size)) == NULL) - do_error(_("couldn't malloc secondary io buffer\n")); - - for (i = 0; i < NUM_SBS; i++) { - if ((sb_bufs[i] = malloc(sbbuf_size)) == NULL) - do_error(_("couldn't malloc sb io buffers\n")); - } } diff --git a/repair/protos.h b/repair/protos.h index 374d3878a..175989bed 100644 --- a/repair/protos.h +++ b/repair/protos.h @@ -47,8 +47,6 @@ void write_primary_sb(xfs_sb_t *sbp, int find_secondary_sb(xfs_sb_t *sb); -int check_growfs(xfs_off_t off, int bufnum, xfs_agnumber_t agnum); - void get_sb_geometry(fs_geometry_t *geo, xfs_sb_t *sbp); diff --git a/repair/sb.c b/repair/sb.c index 3eea31c96..079559be5 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -524,31 +524,6 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno) return (verify_sb(sbp, 0)); } -#if 0 -int -check_growfs(xfs_off_t off, int bufnum, xfs_agnumber_t agnum) -{ - int rval; - - ASSERT(bufnum < NUM_SBS); - - /* try and read it first */ - - if (lseek64(fs_fd, off, SEEK_SET) != off) - return(XR_EOF); - - if ((rval = read(fs_fd, sb_bufs[bufnum], sbbuf_size)) != sbbuf_size) { - /* - * we didn't get a full block so the filesystem - * could not have been grown. return a non-XR_OK - * result code. - */ - return(XR_EOF); - } - - return(get_sb(off, bufnum, agnum)); -} -#endif /* returns element on list with highest reference count */ fs_geo_list_t * -- 2.47.2