Skip to content

Commit

Permalink
netplan: prevent calling close() twice against the same fd
Browse files Browse the repository at this point in the history
Found by Coverity.
  • Loading branch information
daniloegea committed Jul 25, 2023
1 parent 23d2fe9 commit c188d56
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/netplan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ netplan_state_update_yaml_hierarchy(const NetplanState* np_state, const char* de
if (!netplan_netdef_list_write_yaml(np_state, netdefs, out_fd, filename, is_fallback, error))
goto cleanup; // LCOV_EXCL_LINE
close(out_fd);
out_fd = -1;
}

/* Remove any referenced source file that doesn't have any associated data.
Expand All @@ -1286,7 +1287,7 @@ netplan_state_update_yaml_hierarchy(const NetplanState* np_state, const char* de
ret = FALSE;
cleanup:
if (out_fd >= 0)
close(out_fd);
close(out_fd); // LCOV_EXCL_LINE
g_hash_table_destroy(perfile_netdefs);
return ret;
}

0 comments on commit c188d56

Please sign in to comment.