All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: lvm-devel@redhat.com
Subject: Don't leak a file descriptor in fcntl_lock_file(), when fcntl fails.
Date: Sat, 28 Jul 2007 16:40:51 +0200	[thread overview]
Message-ID: <87vec4vbf0.fsf@rho.meyering.net> (raw)

Looking at recent lvm-file.c changes, I stumbled upon a leak
that's surprisingly similar to the one fixed last week in
lib/locking/file_locking.c.  Here's the fix:

diff --git a/WHATS_NEW b/WHATS_NEW
index 44b1e98..243ca25 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.28 -
 ================================
+  Don't leak a file descriptor in fcntl_lock_file(), when fcntl fails.
   Remove create_dir function; use now-equivalent dm_create_dir instead
   Detect stream write failure reliably; new fn: lvm_fclose; use dm_fclose
   Fix clvmd if compiled with gulm support. (2.02.26)
diff --git a/lib/misc/lvm-file.c b/lib/misc/lvm-file.c
index caaebbe..7ce0a0b 100644
--- a/lib/misc/lvm-file.c
+++ b/lib/misc/lvm-file.c
@@ -245,6 +245,7 @@ int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only)

 	if (fcntl(lockfd, F_SETLKW, &lock)) {
 		log_sys_error("fcntl", file);
+		close(lockfd);
 		return -1;
 	}

--
1.5.3.rc3.13.g7ab3



                 reply	other threads:[~2007-07-28 14:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87vec4vbf0.fsf@rho.meyering.net \
    --to=jim@meyering.net \
    --cc=lvm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.