linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 07/10] libext2fs: fix memory leaks on error paths in ext2fs_create_icount_tdb
Date: Tue,  7 Jan 2014 09:53:11 -0500	[thread overview]
Message-ID: <1389106394-31898-7-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1389106394-31898-1-git-send-email-tytso@mit.edu>

Addresses-Coverity-Id: #1138575

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/ext2fs/icount.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c
index c5ebf74..80085e1 100644
--- a/lib/ext2fs/icount.c
+++ b/lib/ext2fs/icount.c
@@ -192,10 +192,12 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
 		goto errout;
 	uuid_unparse(fs->super->s_uuid, uuid);
 	sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
+	icount->tdb_fn = fn;
 	fd = mkstemp(fn);
-	if (fd < 0)
-		return fd;
-
+	if (fd < 0) {
+		retval = errno;
+		goto errout;
+	}
 	/*
 	 * This is an overestimate of the size that we will need; the
 	 * ideal value is the number of used inodes with a count
@@ -206,18 +208,15 @@ errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
 	 */
 	num_inodes = fs->super->s_inodes_count - fs->super->s_free_inodes_count;
 
-	icount->tdb_fn = fn;
 	icount->tdb = tdb_open(fn, num_inodes, TDB_NOLOCK | TDB_NOSYNC,
 			       O_RDWR | O_CREAT | O_TRUNC, 0600);
-	if (icount->tdb) {
-		close(fd);
-		*ret = icount;
-		return 0;
-	}
-
-	retval = errno;
 	close(fd);

  parent reply	other threads:[~2014-01-07 14:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 14:53 [PATCH 01/10] e2fsck: release allocated memory on error or abort in e2fsck_pass1() Theodore Ts'o
2014-01-07 14:53 ` [PATCH 02/10] libext2fs: make ext2fs_group_desc_csum return 0 if meta_csum not enabled Theodore Ts'o
2014-01-07 14:53 ` [PATCH 03/10] e2fsck: fix memory leak on error path in read_bad_blocks_files() Theodore Ts'o
2014-01-07 14:53 ` [PATCH 04/10] libext2fs: remove redundant code in rb_print_stats() Theodore Ts'o
2014-01-07 14:53 ` [PATCH 05/10] libquota: add error checking to quota_write_inode() Theodore Ts'o
2014-01-07 14:53 ` [PATCH 06/10] libquota: add error checking to quota_remove_inode Theodore Ts'o
2014-01-07 14:53 ` Theodore Ts'o [this message]
2014-01-07 14:53 ` [PATCH 08/10] debugfs: remove dead code Theodore Ts'o
2014-01-07 17:14   ` Eric Sandeen
2014-01-07 17:25     ` Theodore Ts'o
2014-01-07 18:58       ` Darrick J. Wong
2014-01-07 14:53 ` [PATCH 09/10] badblocks: print warning if set_o_direct() fails Theodore Ts'o
2014-01-07 14:53 ` [PATCH 10/10] libss: fix memory leak if realloc() fails in ss_parse() Theodore Ts'o

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=1389106394-31898-7-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    /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).