]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfs_fsr: fix leaks & catch error in fsrfile()
authorEric Sandeen <sandeen@redhat.com>
Mon, 15 Sep 2014 23:18:41 +0000 (09:18 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 15 Sep 2014 23:18:41 +0000 (09:18 +1000)
commit4f10a2fb156fe658ecaf1ae558fd7fc9e821527c
tree0d38399b1373972fd4876fb97d8d59a5dc620fe3
parent713ba3f2c7f6d28a78df4e774cb8c3bd9ff12154
xfs_fsr: fix leaks & catch error in fsrfile()

The allocated fshandlep leaks on most error paths; restructure with
an out: target that does all necessary freeing, and initialize
filehandles to -1 so that we know whether they need to be closed on
the error path.

While we're at it, if gettmpname() fails, we still return 0 for an
error, because error is initialized to 0 and only set otherwise by
fsrfile_common.  So if gettmpname() fails, we return success from
the function even though we did no work.  Fix that as well by
initializing error to -1.

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