]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: fix leaks in parent_list()
authorEric Sandeen <sandeen@redhat.com>
Mon, 15 Sep 2014 23:19:24 +0000 (09:19 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 15 Sep 2014 23:19:24 +0000 (09:19 +1000)
parent_list() has instances where a handle is leaked, both by going
out of scope, and on error paths.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
io/parent.c

index 56e126d324b06669d8987f6605342d3c03bfb7bb..0313119fa1b7837a3dd5df6969e84b9b608e4cef 100644 (file)
@@ -293,7 +293,7 @@ print_parent_entry(parent_t *parent, int fullpath)
 static int
 parent_list(int fullpath)
 {
-       void *handlep;
+       void *handlep = NULL;
        size_t handlen;
        int error, i;
        int retval = 1;
@@ -313,6 +313,7 @@ parent_list(int fullpath)
                                progname, path, strerror(errno));
                        goto error;
                }
+               free_handle(fshandle, fshlen);
        }
 
        if (path_to_handle(path, &handlep, &handlen) != 0) {
@@ -325,7 +326,7 @@ parent_list(int fullpath)
                if (!parentbuf) {
                        fprintf(stderr, _("%s: unable to allocate parent buffer: %s\n"),
                                progname, strerror(errno));
-                       return 1;
+                       goto error;
                }
 
                if (fullpath) {
@@ -365,6 +366,7 @@ parent_list(int fullpath)
 
        retval = 0;
 error:
+       free(handlep);
        free(parentbuf);
        return retval;
 }