From ff36fbae4d4e6a18c43c0693fb16f0abfc411e32 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 9 Jun 2015 15:24:51 +0200 Subject: [PATCH] btrfs-progs: cleanup after errors in open_file_or_dir3 We should zero the dirstream in case we close it ourselves, so the caller does not do it again. Most current callers do not do that and exit immediatelly. Signed-off-by: David Sterba --- utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 17837377..41a04bdb 100644 --- a/utils.c +++ b/utils.c @@ -1915,8 +1915,10 @@ int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags) } if (fd < 0) { fd = -1; - if (*dirstream) + if (*dirstream) { closedir(*dirstream); + *dirstream = NULL; + } } return fd; }