summaryrefslogtreecommitdiff
path: root/cmds-scrub.c
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-01-23 14:36:03 -0800
committerZach Brown <zab@redhat.com>2013-02-05 16:09:40 -0800
commitcb4c601a4e7cf33102a0667799eb0ec603067ee8 (patch)
tree5e5006aa2e0496e53c04294acf1769fef7bf5da6 /cmds-scrub.c
parent09fac3824db462368f24d3dd4deccafedf5b3c8c (diff)
btrfs-progs: fix scrub socket leak
If connection fails the socket is leaked when the status file is used instead. Close it to trivially cut down on fd use and to bring down the noise in static code analysis. Signed-off-by: Zach Brown <zab@redhat.com>
Diffstat (limited to 'cmds-scrub.c')
-rw-r--r--cmds-scrub.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c
index efdfdb4f..70d26832 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -1584,6 +1584,7 @@ static int cmd_scrub_status(int argc, char **argv)
addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
ret = connect(fdres, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1) {
+ close(fdres);
fdres = scrub_open_file_r(SCRUB_DATA_FILE, fsid);
if (fdres < 0 && fdres != -ENOENT) {
fprintf(stderr, "WARNING: failed to open status file: "