linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jes.Sorensen@redhat.com
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, dledford@redhat.com
Subject: [PATCH 07/12] close_aa(): Verify file descriptors are valid before trying to close them
Date: Wed,  2 Nov 2011 15:42:12 +0100	[thread overview]
Message-ID: <1320244937-9739-8-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1320244937-9739-1-git-send-email-Jes.Sorensen@redhat.com>

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 managemon.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/managemon.c b/managemon.c
index fceaeb9..cde0d8b 100644
--- a/managemon.c
+++ b/managemon.c
@@ -117,11 +117,16 @@ static void close_aa(struct active_array *aa)
 		close(d->state_fd);
 	}
 
-	close(aa->action_fd);
-	close(aa->info.state_fd);
-	close(aa->resync_start_fd);
-	close(aa->metadata_fd);
-	close(aa->sync_completed_fd);
+	if (aa->action_fd >= 0)
+		close(aa->action_fd);
+	if (aa->info.state_fd >= 0)
+		close(aa->info.state_fd);
+	if (aa->resync_start_fd >= 0)
+		close(aa->resync_start_fd);
+	if (aa->metadata_fd >= 0)
+		close(aa->metadata_fd);
+	if (aa->sync_completed_fd >= 0)
+		close(aa->sync_completed_fd);
 }
 
 static void free_aa(struct active_array *aa)
-- 
1.7.6.4


  parent reply	other threads:[~2011-11-02 14:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 14:42 [PATCH 00/12] More leak and NULL pointer dereference fixes Jes.Sorensen
2011-11-02 14:42 ` [PATCH 01/12] mdadm: add missing break for UpdateSubarray Jes.Sorensen
2011-11-02 14:42 ` [PATCH 02/12] ping_monitor(): check file descriptor is valid before using and closing it Jes.Sorensen
2011-11-02 14:42 ` [PATCH 03/12] mdstat_read(): Check return value of dup() before using file descriptor Jes.Sorensen
2011-11-02 14:42 ` [PATCH 04/12] get_component_size(): Check read() return value for error before using it Jes.Sorensen
2011-11-02 14:42 ` [PATCH 05/12] array_try_spare(): open_dev() returns -1 on error, not zero Jes.Sorensen
2011-11-02 14:42 ` [PATCH 06/12] disk_init_and_add(): Fail if opening sysfs file descriptors fail Jes.Sorensen
2011-11-02 14:42 ` Jes.Sorensen [this message]
2011-11-02 14:42 ` [PATCH 08/12] ahci_enumerate_ports(): Don't close fd that failed to open Jes.Sorensen
2011-11-02 14:42 ` [PATCH 09/12] unblock_monitor(): Check sra is valid before dereferencing Jes.Sorensen
2011-11-02 14:42 ` [PATCH 10/12] Manage_ro(): Check pointer rather than dereferencing it Jes.Sorensen
2011-11-02 14:42 ` [PATCH 11/12] fd2devname(): Don't dereference NULL pointer Jes.Sorensen
2011-11-02 14:42 ` [PATCH 12/12] match_metadata_desc(): Fix memory leak Jes.Sorensen
2011-11-02 21:12 ` [PATCH 00/12] More leak and NULL pointer dereference fixes NeilBrown
2011-11-03 12:40   ` Jes Sorensen

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=1320244937-9739-8-git-send-email-Jes.Sorensen@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=dledford@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    /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).