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>
master
Zach Brown 2013-01-23 14:41:03 -08:00
parent cb4c601a4e
commit f4dc05bf76
1 changed files with 2 additions and 2 deletions

View File

@ -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;