public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: zkabelac@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/config/config.c
Date: Tue, 30 Nov 2010 22:23:00 -0000	[thread overview]
Message-ID: <20101130222337.8129.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-30 22:23:35

Modified files:
	.              : WHATS_NEW 
	lib/config     : config.c 

Log message:
	Add missing test for failed pool allocation
	
	Add test for NULL from dm_poll_create.
	Reorder dm_pool_destroy() before file close and add label out:.
	Avoid leaking file descriptor if the allocation fails.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1816&r2=1.1817
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84

--- LVM2/WHATS_NEW	2010/11/30 22:16:25	1.1816
+++ LVM2/WHATS_NEW	2010/11/30 22:23:35	1.1817
@@ -1,5 +1,6 @@
 Version 2.02.78 - 
 ====================================
+  Add missing test for failed pool allocation in write_config_node().
   Replace snprintf with dm_snprintf in clvmd-command.c.
   Check reallocated buffer for NULL before use in clvmd do_command().
   Fix memory leak when VG allocation policy in metadata is invalid.
--- LVM2/lib/config/config.c	2010/11/23 15:08:57	1.83
+++ LVM2/lib/config/config.c	2010/11/30 22:23:35	1.84
@@ -511,7 +511,8 @@
 {
 	struct output_line outline;
 	outline.fp = NULL;
-	outline.mem = dm_pool_create("config_line", 1024);
+	if (!(outline.mem = dm_pool_create("config_line", 1024)))
+		return_0;
 	outline.putline = putline;
 	outline.putline_baton = baton;
 	if (!_write_config(cn, 0, &outline, 0)) {
@@ -538,7 +539,10 @@
 		return 0;
 	}
 
-	outline.mem = dm_pool_create("config_line", 1024);
+	if (!(outline.mem = dm_pool_create("config_line", 1024))) {
+		r = 0;
+		goto_out;
+	}
 
 	log_verbose("Dumping configuration to %s", file);
 	if (!argc) {
@@ -559,12 +563,14 @@
 		argv++;
 	}
 
+	dm_pool_destroy(outline.mem);
+
+out:
 	if (outline.fp && lvm_fclose(outline.fp, file)) {
 		stack;
 		r = 0;
 	}
 
-	dm_pool_destroy(outline.mem);
 	return r;
 }
 


             reply	other threads:[~2010-11-30 22:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 22:23 zkabelac [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-07-21 13:23 zkabelac
2010-12-20 13:53 zkabelac
2008-06-03 17:51 agk
2007-07-20 15:26 meyering
2007-07-08 22:51 agk
2007-03-08 19:22 agk
2007-01-17 16:23 agk
2006-11-16 17:36 agk
2006-04-28 13:31 agk

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=20101130222337.8129.qmail@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).