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@google.com>, "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH 1/4] libss: fix potential memory leak on realloc() failure
Date: Sun,  5 Jan 2014 01:26:40 -0500	[thread overview]
Message-ID: <1388903203-5067-1-git-send-email-tytso@mit.edu> (raw)

From: Theodore Ts'o <tytso@google.com>

Addresses-Coverity-ID: #295143

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/ss/invocation.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c
index 61c2e35..924427a 100644
--- a/lib/ss/invocation.c
+++ b/lib/ss/invocation.c
@@ -28,7 +28,7 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string,
 {
 	register int sci_idx;
 	register ss_data *new_table;
-	register ss_data **table;
+	register ss_data **table, **rt;
 
 	*code_ptr = 0;
 	table = _ss_table;
@@ -42,10 +42,10 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string,
 
 	for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++)
 		;
-	table = (ss_data **) realloc((char *)table,
-				     ((unsigned)sci_idx+2)*size);
-	if (table == NULL) {
-		*code_ptr = errno;
+	rt = (ss_data **) realloc((char *)table, ((unsigned)sci_idx+2)*size);
+	if (rt == NULL) {
+		*code_ptr = ENOMEM;
+		free(table);
 		return 0;
 	}
 	table[sci_idx+1] = (ss_data *) NULL;
-- 
1.8.5.rc3.362.gdf10213


             reply	other threads:[~2014-01-05  6:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-05  6:26 Theodore Ts'o [this message]
2014-01-05  6:26 ` [PATCH 2/4] libext2fs: fix potential memory leak in qcow2_write_raw_image() Theodore Ts'o
2014-01-05  6:26 ` [PATCH 3/4] test_extents: fix a possible memory leak Theodore Ts'o
2014-01-05  6:26 ` [PATCH 4/4] libblkid: fix memory overrun in probe_lvm2 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=1388903203-5067-1-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@google.com \
    /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).