Skip to content

Commit 20c76e2

Browse files
committed
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: 99feaa7 ("s390/kexec_file: Create ipl report and pass to next kernel") Signed-off-by: Heiko Carstens <[email protected]>
1 parent 3b90954 commit 20c76e2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

arch/s390/kernel/ipl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ void *ipl_report_finish(struct ipl_report *report)
21562156

21572157
buf = vzalloc(report->size);
21582158
if (!buf)
2159-
return ERR_PTR(-ENOMEM);
2159+
goto out;
21602160
ptr = buf;
21612161

21622162
memcpy(ptr, report->ipib, report->ipib->hdr.len);
@@ -2195,6 +2195,7 @@ void *ipl_report_finish(struct ipl_report *report)
21952195
}
21962196

21972197
BUG_ON(ptr > buf + report->size);
2198+
out:
21982199
return buf;
21992200
}
22002201

arch/s390/kernel/machine_kexec_file.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
170170
struct kexec_buf buf;
171171
unsigned long addr;
172172
void *ptr, *end;
173+
int ret;
173174

174175
buf.image = image;
175176

@@ -199,7 +200,10 @@ static int kexec_file_add_ipl_report(struct kimage *image,
199200
ptr += len;
200201
}
201202

203+
ret = -ENOMEM;
202204
buf.buffer = ipl_report_finish(data->report);
205+
if (!buf.buffer)
206+
goto out;
203207
buf.bufsz = data->report->size;
204208
buf.memsz = buf.bufsz;
205209

@@ -209,7 +213,9 @@ static int kexec_file_add_ipl_report(struct kimage *image,
209213
data->kernel_buf + offsetof(struct lowcore, ipl_parmblock_ptr);
210214
*lc_ipl_parmblock_ptr = (__u32)buf.mem;
211215

212-
return kexec_add_buffer(&buf);
216+
ret = kexec_add_buffer(&buf);
217+
out:
218+
return ret;
213219
}
214220

215221
void *kexec_file_add_components(struct kimage *image,

0 commit comments

Comments
 (0)