summaryrefslogtreecommitdiff
path: root/cmds-scrub.c
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-01-23 14:41:03 -0800
committerZach Brown <zab@redhat.com>2013-02-05 16:09:40 -0800
commitf4dc05bf76fbb2c9c2561ff6d3bd3f018829ac3a (patch)
treeb995da8f5c0c14309833197930e115c27e28b6a9 /cmds-scrub.c
parentcb4c601a4e7cf33102a0667799eb0ec603067ee8 (diff)
btrfs-progs: scrub can leak fd 0
< 0 is returned for errors opening the file, this code could leak fd 0. Signed-off-by: Zach Brown <zab@redhat.com>
Diffstat (limited to 'cmds-scrub.c')
-rw-r--r--cmds-scrub.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c
index 70d26832..8655d3d9 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -754,7 +754,7 @@ static int scrub_write_progress(pthread_mutex_t *m, const char *fsid,
{
int ret;
int err;
- int fd = 0;
+ int fd = -1;
int old;
ret = pthread_mutex_lock(m);
@@ -782,7 +782,7 @@ static int scrub_write_progress(pthread_mutex_t *m, const char *fsid,
goto out;
out:
- if (fd > 0) {
+ if (fd >= 0) {
ret = close(fd);
if (ret)
err = -errno;