mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2025-01-26 13:44:06 +08:00
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>
This commit is contained in:
parent
cb4c601a4e
commit
f4dc05bf76
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user