Commit 20c76e24 authored by Heiko Carstens's avatar Heiko Carstens

s390/kexec: fix return code handling

kexec_file_add_ipl_report ignores that ipl_report_finish may fail and
can return an error pointer instead of a valid pointer.
Fix this and simplify by returning NULL in case of an error and let
the only caller handle this case.

Fixes: 99feaa71 ("s390/kexec_file: Create ipl report and pass to next kernel")
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 3b909544
...@@ -2156,7 +2156,7 @@ void *ipl_report_finish(struct ipl_report *report) ...@@ -2156,7 +2156,7 @@ void *ipl_report_finish(struct ipl_report *report)
buf = vzalloc(report->size); buf = vzalloc(report->size);
if (!buf) if (!buf)
return ERR_PTR(-ENOMEM); goto out;
ptr = buf; ptr = buf;
memcpy(ptr, report->ipib, report->ipib->hdr.len); memcpy(ptr, report->ipib, report->ipib->hdr.len);
...@@ -2195,6 +2195,7 @@ void *ipl_report_finish(struct ipl_report *report) ...@@ -2195,6 +2195,7 @@ void *ipl_report_finish(struct ipl_report *report)
} }
BUG_ON(ptr > buf + report->size); BUG_ON(ptr > buf + report->size);
out:
return buf; return buf;
} }
......
...@@ -170,6 +170,7 @@ static int kexec_file_add_ipl_report(struct kimage *image, ...@@ -170,6 +170,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
struct kexec_buf buf; struct kexec_buf buf;
unsigned long addr; unsigned long addr;
void *ptr, *end; void *ptr, *end;
int ret;
buf.image = image; buf.image = image;
...@@ -199,7 +200,10 @@ static int kexec_file_add_ipl_report(struct kimage *image, ...@@ -199,7 +200,10 @@ static int kexec_file_add_ipl_report(struct kimage *image,
ptr += len; ptr += len;
} }
ret = -ENOMEM;
buf.buffer = ipl_report_finish(data->report); buf.buffer = ipl_report_finish(data->report);
if (!buf.buffer)
goto out;
buf.bufsz = data->report->size; buf.bufsz = data->report->size;
buf.memsz = buf.bufsz; buf.memsz = buf.bufsz;
...@@ -209,7 +213,9 @@ static int kexec_file_add_ipl_report(struct kimage *image, ...@@ -209,7 +213,9 @@ static int kexec_file_add_ipl_report(struct kimage *image,
data->kernel_buf + offsetof(struct lowcore, ipl_parmblock_ptr); data->kernel_buf + offsetof(struct lowcore, ipl_parmblock_ptr);
*lc_ipl_parmblock_ptr = (__u32)buf.mem; *lc_ipl_parmblock_ptr = (__u32)buf.mem;
return kexec_add_buffer(&buf); ret = kexec_add_buffer(&buf);
out:
return ret;
} }
void *kexec_file_add_components(struct kimage *image, void *kexec_file_add_components(struct kimage *image,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment