btrfs-progs: fix scrub socket leak
authorZach Brown <zab@redhat.com>
Wed, 23 Jan 2013 22:36:03 +0000 (14:36 -0800)
committerZach Brown <zab@redhat.com>
Wed, 6 Feb 2013 00:09:40 +0000 (16:09 -0800)
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>
cmds-scrub.c

index efdfdb4..70d2683 100644 (file)
@@ -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: "