All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] super-intel.c: Don't try to close negative fd
@ 2012-05-04 13:41 Jes.Sorensen
  2012-05-04 13:41 ` [PATCH 2/2] super-intel.c: Fix resource leak from opendir() Jes.Sorensen
  2012-05-04 18:00 ` [PATCH 1/2] super-intel.c: Don't try to close negative fd Dan Williams
  0 siblings, 2 replies; 4+ messages in thread
From: Jes.Sorensen @ 2012-05-04 13:41 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

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

This should be harmless, but lets be consistent and not try to close a
negative file descripter.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 super-intel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 2e85b6b..ca15703 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4353,7 +4353,7 @@ static int get_super_block(struct intel_super **super_list, int devnum, char *de
 	} else {
 		if (s)
 			free(s);
-		if (dfd)
+		if (dfd >= 0)
 			close(dfd);
 	}
 	if ((dfd >= 0) && (!keep_fd))
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] super-intel.c: Fix resource leak from opendir()
  2012-05-04 13:41 [PATCH 1/2] super-intel.c: Don't try to close negative fd Jes.Sorensen
@ 2012-05-04 13:41 ` Jes.Sorensen
  2012-05-04 18:00 ` [PATCH 1/2] super-intel.c: Don't try to close negative fd Dan Williams
  1 sibling, 0 replies; 4+ messages in thread
From: Jes.Sorensen @ 2012-05-04 13:41 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

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

Use closedir() on dirp from opendir() to avoid resource leaking.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 super-intel.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index ca15703..e2ed95a 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5686,6 +5686,7 @@ get_devices(const char *hba_path)
 			free(dv);
 		}
 	}
+	closedir(dir);
 	return devlist;
 }
 
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] super-intel.c: Don't try to close negative fd
  2012-05-04 13:41 [PATCH 1/2] super-intel.c: Don't try to close negative fd Jes.Sorensen
  2012-05-04 13:41 ` [PATCH 2/2] super-intel.c: Fix resource leak from opendir() Jes.Sorensen
@ 2012-05-04 18:00 ` Dan Williams
  2012-05-06 23:10   ` NeilBrown
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Williams @ 2012-05-04 18:00 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: neilb, linux-raid

On Fri, May 4, 2012 at 6:41 AM,  <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> This should be harmless, but lets be consistent and not try to close a
> negative file descripter.
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---

Patch 1 and 2, Acked-by: Dan Williams <dan.j.williams@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] super-intel.c: Don't try to close negative fd
  2012-05-04 18:00 ` [PATCH 1/2] super-intel.c: Don't try to close negative fd Dan Williams
@ 2012-05-06 23:10   ` NeilBrown
  0 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2012-05-06 23:10 UTC (permalink / raw)
  To: Dan Williams; +Cc: Jes.Sorensen, linux-raid

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

On Fri, 4 May 2012 11:00:15 -0700 Dan Williams <dan.j.williams@intel.com>
wrote:

> On Fri, May 4, 2012 at 6:41 AM,  <Jes.Sorensen@redhat.com> wrote:
> > From: Jes Sorensen <Jes.Sorensen@redhat.com>
> >
> > This should be harmless, but lets be consistent and not try to close a
> > negative file descripter.
> >
> > Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> > ---
> 
> Patch 1 and 2, Acked-by: Dan Williams <dan.j.williams@intel.com>

Thanks to you both.
Patches applied.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-06 23:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-04 13:41 [PATCH 1/2] super-intel.c: Don't try to close negative fd Jes.Sorensen
2012-05-04 13:41 ` [PATCH 2/2] super-intel.c: Fix resource leak from opendir() Jes.Sorensen
2012-05-04 18:00 ` [PATCH 1/2] super-intel.c: Don't try to close negative fd Dan Williams
2012-05-06 23:10   ` NeilBrown

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.