btrfs-progs: fragments, close output file on error
authorDavid Sterba <dsterba@suse.cz>
Fri, 19 Dec 2014 15:15:39 +0000 (16:15 +0100)
committerDavid Sterba <dsterba@suse.cz>
Fri, 19 Dec 2014 17:04:21 +0000 (18:04 +0100)
Resolves-Coverity-CID: 1258794
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-fragments.c

index d03c2c3..360f10f 100644 (file)
@@ -233,7 +233,7 @@ list_fragments(int fd, u64 flags, char *dir)
                ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
                if (ret < 0) {
                        fprintf(stderr, "ERROR: can't perform the search\n");
-                       return ret;
+                       goto out_close;
                }
                /* the ioctl returns the number of item it found in nr_items */
                if (sk->nr_items == 0)
@@ -373,7 +373,10 @@ skip:;
                fprintf(html, "</p>");
        }
        fprintf(html, "</body></html>\n");
-       
+
+out_close:
+       fclose(html);
+
        return ret;
 }