Fix wrongly closing file descripter for disk when failing to add disk. To avoid this, memset it with 0 at initialization. Also check if sd->sd_list[0] is NULL before freeing it since it could be NULL if failing in the middle of adding disk. Signed-off-by: HATAYAMA Daisuke <d.hatayama@xxxxxxxxxxxxxx> --- sadump.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/sadump.c b/sadump.c index 0eef2f4..3178c4c 100644 --- a/sadump.c +++ b/sadump.c @@ -69,7 +69,8 @@ sadump_cleanup_sadump_data(void) if (sd->flags & SADUMP_DISKSET) { for (i = 1; i < sd->sd_list_len; ++i) { - close(sd->sd_list[i]->dfd); + if (sd->sd_list[i]->dfd) + close(sd->sd_list[i]->dfd); free(sd->sd_list[i]->header); free(sd->sd_list[i]); } @@ -83,7 +84,8 @@ sadump_cleanup_sadump_data(void) free(sd->dumpable_bitmap); free(sd->page_buf); free(sd->block_table); - free(sd->sd_list[0]); + if (sd->sd_list[0]) + free(sd->sd_list[0]); memset(&sadump_data, 0, sizeof(sadump_data)); @@ -605,7 +607,7 @@ open_disk(char *file) } return FALSE; } - + memset(this_disk, 0, sizeof(*this_disk)); sd->sd_list[sd->sd_list_len - 1] = this_disk; this_disk->dfd = open(file, O_RDONLY);
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility