From 9aa59bfc4b0129d6181f9bef0008e73e6a120742 Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Wed, 27 Oct 2021 08:21:04 +0200 Subject: [PATCH] zipl: Fix stage2 disk block memory leaks in bootmap_install_stages() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a bug that fails to release stage2 disk blocks in case the installation of stage1b disk blocks has failed. Signed-off-by: Alexander Egorenkov Suggested-by: Marc Hartmayer Reviewed-by: Marc Hartmayer Acked-by: Alexander Gordeev Signed-off-by: Jan Höppner --- zipl/src/bootmap.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index d9f4a37b..6c7cb2fc 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -1165,6 +1165,7 @@ bootmap_install_stages(struct job_data *job, struct disk_info *info, int fd, blocknum_t stage2_count; size_t stage2_size; void *stage2_data; + int rc; switch (info->type) { case disk_type_fba: @@ -1176,10 +1177,11 @@ bootmap_install_stages(struct job_data *job, struct disk_info *info, int fd, free(stage2_data); if (stage2_count == 0) return -1; - if (install_fba_stage1b(fd, stage1b_list, stage1b_count, - stage2_list, stage2_count, info)) - return -1; + rc = install_fba_stage1b(fd, stage1b_list, stage1b_count, + stage2_list, stage2_count, info); free(stage2_list); + if (rc) + return -1; break; case disk_type_eckd_ldl: case disk_type_eckd_cdl: @@ -1191,10 +1193,11 @@ bootmap_install_stages(struct job_data *job, struct disk_info *info, int fd, free(stage2_data); if (stage2_count == 0) return -1; - if (install_eckd_stage1b(fd, stage1b_list, stage1b_count, - stage2_list, stage2_count, info)) - return -1; + rc = install_eckd_stage1b(fd, stage1b_list, stage1b_count, + stage2_list, stage2_count, info); free(stage2_list); + if (rc) + return -1; break; case disk_type_scsi: case disk_type_diag: