From 85b8f7affa5fadb1972e82e04cc3d1828966b238 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Thu, 12 Dec 2013 12:52:00 -0500 Subject: [PATCH] debugfs: don't leak mmp_s memory (on error path) ext2fs_free_mem() takes a pointer to a pointer, similar to ext2fs_get_mem(). Improve the documentation, and fix debugfs. Signed-off-by: Darrick J. Wong Signed-off-by: "Theodore Ts'o" --- debugfs/set_fields.c | 2 +- lib/ext2fs/ext2fs.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c index b09e2f89f..064de395d 100644 --- a/debugfs/set_fields.c +++ b/debugfs/set_fields.c @@ -802,7 +802,7 @@ void do_set_mmp_value(int argc, char *argv[]) if (retval) { com_err(argv[0], retval, "reading MMP block %llu.\n", (long long)current_fs->super->s_mmp_block); - ext2fs_free_mem(mmp_s); + ext2fs_free_mem(&mmp_s); return; } current_fs->mmp_buf = mmp_s; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 9f62cbbe6..c982327ec 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1517,7 +1517,7 @@ extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b); #ifndef EXT2_CUSTOM_MEMORY_ROUTINES #include /* - * Allocate memory + * Allocate memory. The 'ptr' arg must point to a pointer. */ _INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr) { @@ -1564,7 +1564,7 @@ _INLINE_ errcode_t ext2fs_get_arrayzero(unsigned long count, } /* - * Free memory + * Free memory. The 'ptr' arg must point to a pointer. */ _INLINE_ errcode_t ext2fs_free_mem(void *ptr) { @@ -1578,7 +1578,7 @@ _INLINE_ errcode_t ext2fs_free_mem(void *ptr) } /* - * Resize memory + * Resize memory. The 'ptr' arg must point to a pointer. */ _INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size, unsigned long size, void *ptr) -- 2.39.2