* [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
* Re: [PATCH] Avoid double close()
2013-07-30 16:30 [PATCH] Avoid double close() Jes.Sorensen
@ 2013-07-30 22:52 ` NeilBrown
0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2013-07-30 22:52 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: linux-raid
[-- Attachment #1: Type: text/plain, Size: 779 bytes --]
On Tue, 30 Jul 2013 18:30:03 +0200 Jes.Sorensen@redhat.com wrote:
> 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;
Applied, thanks.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [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).