From: Jes.Sorensen@redhat.com
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, dledford@redhat.com
Subject: [PATCH 02/12] ping_monitor(): check file descriptor is valid before using and closing it
Date: Wed, 2 Nov 2011 15:42:07 +0100 [thread overview]
Message-ID: <1320244937-9739-3-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>
---
msg.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/msg.c b/msg.c
index 98d6d13..87d3b8d 100644
--- a/msg.c
+++ b/msg.c
@@ -207,9 +207,14 @@ int fping_monitor(int sfd)
int ping_monitor(char *devname)
{
int sfd = connect_monitor(devname);
- int err = fping_monitor(sfd);
+ int err;
+
+ if (sfd >= 0) {
+ err = fping_monitor(sfd);
+ close(sfd);
+ } else
+ err = -1;
- close(sfd);
return err;
}
--
1.7.6.4
next prev 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 ` Jes.Sorensen [this message]
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 ` [PATCH 07/12] close_aa(): Verify file descriptors are valid before trying to close them Jes.Sorensen
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-3-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).