If for some reason we get an error when trying to write the inventory file, we first need to close the file and then exit the function. Signed-off-by: Dan Ben Yosef <danby@xxxxxxxxxxxx> Signed-off-by: Alex Netes <alexne@xxxxxxxxxxxx> --- osmtest/osmtest.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osmtest/osmtest.c b/osmtest/osmtest.c index c8c8e71..79e8af8 100644 --- a/osmtest/osmtest.c +++ b/osmtest/osmtest.c @@ -2545,22 +2545,24 @@ osmtest_create_inventory_file(IN osmtest_t * const p_osmt) /* HACK: the order is important: nodes ports paths */ status = osmtest_write_all_node_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; status = osmtest_write_all_port_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; if (!p_osmt->opt.ignore_path_records) { status = osmtest_write_all_path_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; } status = osmtest_write_all_link_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; + +CloseFile: fclose(fh); Exit: -- 2.8.4