zipl: check_common_ipl_data: fix memory leak of @buffer

Related Valgrind output:
  ==1073934== 241,722,000 bytes in 30 blocks are definitely lost in loss record 2 of 2
  ==1073934==    at 0x484417C: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-s390x-linux.so)
  ==1073934==    by 0x1006B8D: misc_malloc (misc.c:33)
  ==1073934==    by 0x1006B8D: misc_read_file (misc.c:150)
  ==1073934==    by 0x100DACD: check_common_ipl_data (job.c:774)
  ==1073934==    by 0x100FE2F: check_job_ipl_data (job.c:827)
  ==1073934==    by 0x100FE2F: check_job_menu_data (job.c:999)
  ==1073934==    by 0x100FE2F: check_job_data (job.c:1139)
  ==1073934==    by 0x100FE2F: job_get (job.c:2011)
  ==1073934==    by 0x1006335: main (zipl.c:141)

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Acked-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2023-03-13 19:29:02 +01:00
committed by Steffen Eiden
parent ae824745a0
commit 2c7e61a6c7

View File

@@ -787,6 +787,7 @@ check_common_ipl_data(struct job_common_ipl_data *common, const char *section,
}
if (size < MAX_COMMAND_LINE_SIZE + sizeof(uint64_t)) {
error_text_section("Image file", section, common->image);
free(buffer);
return -1;
}
@@ -799,8 +800,11 @@ check_common_ipl_data(struct job_common_ipl_data *common, const char *section,
error_text("The length of the parameters line "
"(%d bytes) exceeds the allowed maximum "
"(%d bytes) in section '%s'", len, max_parm_size, section);
free(buffer);
return -1;
}
free(buffer);
buffer = NULL;
}
skip_image:
if (common->ramdisk != NULL) {