linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Avoid double close()
@ 2013-07-30 16:30 Jes.Sorensen
  2013-07-30 22:52 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Jes.Sorensen @ 2013-07-30 16:30 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

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

Coverity discovered a possible double close(fd2) in Grow.c. Avoided by
invalidating fd2 after the first close.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 Grow.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Grow.c b/Grow.c
index c1ae6e8..ff4ed5d 100644
--- a/Grow.c
+++ b/Grow.c
@@ -4685,6 +4685,8 @@ int Grow_continue_command(char *devname, int fd,
 				continue;
 			err = st->ss->load_super(st, fd2, NULL);
 			close(fd2);
+			/* invalidate fd2 to avoid possible double close() */
+			fd2 = -1;
 			if (err)
 				continue;
 			break;
-- 
1.8.3.1


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

end of thread, other threads:[~2013-07-30 22:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-30 16:30 [PATCH] Avoid double close() Jes.Sorensen
2013-07-30 22:52 ` NeilBrown

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).