[PATCH v2] xfsprogs: fix resource leak in longform_dir2_rebuild()
Dave Chinner
david at fromorbit.com
Tue Oct 15 16:39:36 CDT 2013
On Tue, Oct 15, 2013 at 10:55:31AM +0800, Li Zhong wrote:
> coverity scan 997010 reported following leak:
>
> 1309 if (error) {
> 1310 do_warn(
> 1311 _("space reservation failed (%d), filesystem may be out of space\n"),
> 1312 error);
> 25. Breaking from loop
> 1313 break;
> 1314 }
>
> ......
>
> 1342 libxfs_trans_commit(tp,
> 1343 XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC);
> 1344 }
>
> CID 997010 (#1 of 1): Resource leak (RESOURCE_LEAK)
> 26. leaked_storage: Variable "tp" going out of scope leaks the storage it points to.
> 1345}
>
> Though not reported by coverity, it seems that there might be some entries in
> flist which needs to be freed in the failure case below libxfs_dir_createname(),
> and libxfs_bunmapi().
>
> The fix cleans up the code by stacking the error handling at the end of the
> function, and jumping to the error handler label for the above cases. (fail
> directly by calling res_failed() for reservation failure.)
>
> Signed-off-by: Li Zhong <zhong at linux.vnet.ibm.com>
Looks much better. Thanks! :)
Reviewed-by: Dave Chinner <dchinner at redhat.com>
--
Dave Chinner
david at fromorbit.com
More information about the xfs
mailing list