From: Baoquan He <bhe@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-s390@vger.kernel.org, kexec@lists.infradead.org, hca@linux.ibm.com, prudo@redhat.com, Baoquan He <bhe@redhat.com> Subject: [PATCH v2 1/2] s390/kexec: check the return value of ipl_report_finish Date: Tue, 16 Nov 2021 11:25:56 +0800 [thread overview] Message-ID: <20211116032557.14075-1-bhe@redhat.com> (raw) In function ipl_report_finish(), it could fail by memory allocation failure, so check the return value to handle the case. Signed-off-by: Baoquan He <bhe@redhat.com> --- arch/s390/include/asm/ipl.h | 2 +- arch/s390/kernel/ipl.c | 6 ++++-- arch/s390/kernel/machine_kexec_file.c | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h index 3f8ee257f9aa..864ab5d2890c 100644 --- a/arch/s390/include/asm/ipl.h +++ b/arch/s390/include/asm/ipl.h @@ -122,7 +122,7 @@ struct ipl_report_certificate { struct kexec_buf; struct ipl_report *ipl_report_init(struct ipl_parameter_block *ipib); -void *ipl_report_finish(struct ipl_report *report); +int ipl_report_finish(struct ipl_report *report, void **ipl_buf); int ipl_report_free(struct ipl_report *report); int ipl_report_add_component(struct ipl_report *report, struct kexec_buf *kbuf, unsigned char flags, unsigned short cert); diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c index e2cc35775b99..a0af0b23148d 100644 --- a/arch/s390/kernel/ipl.c +++ b/arch/s390/kernel/ipl.c @@ -2144,7 +2144,7 @@ struct ipl_report *ipl_report_init(struct ipl_parameter_block *ipib) return report; } -void *ipl_report_finish(struct ipl_report *report) +int ipl_report_finish(struct ipl_report *report, void **ipl_buf) { struct ipl_report_certificate *cert; struct ipl_report_component *comp; @@ -2195,7 +2195,9 @@ void *ipl_report_finish(struct ipl_report *report) } BUG_ON(ptr > buf + report->size); - return buf; + *ipl_buf = buf; + + return 0; } int ipl_report_free(struct ipl_report *report) diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c index 528edff085d9..17e961975624 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -170,6 +170,7 @@ static int kexec_file_add_ipl_report(struct kimage *image, struct kexec_buf buf; unsigned long addr; void *ptr, *end; + int ret; buf.image = image; @@ -199,7 +200,9 @@ static int kexec_file_add_ipl_report(struct kimage *image, ptr += len; } - buf.buffer = ipl_report_finish(data->report); + ret = ipl_report_finish(data->report, &buf.buffer); + if (ret) + return ret; buf.bufsz = data->report->size; buf.memsz = buf.bufsz; -- 2.17.2
WARNING: multiple messages have this Message-ID (diff)
From: Baoquan He <bhe@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-s390@vger.kernel.org, kexec@lists.infradead.org, hca@linux.ibm.com, prudo@redhat.com, Baoquan He <bhe@redhat.com> Subject: [PATCH v2 1/2] s390/kexec: check the return value of ipl_report_finish Date: Tue, 16 Nov 2021 11:25:56 +0800 [thread overview] Message-ID: <20211116032557.14075-1-bhe@redhat.com> (raw) In function ipl_report_finish(), it could fail by memory allocation failure, so check the return value to handle the case. Signed-off-by: Baoquan He <bhe@redhat.com> --- arch/s390/include/asm/ipl.h | 2 +- arch/s390/kernel/ipl.c | 6 ++++-- arch/s390/kernel/machine_kexec_file.c | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h index 3f8ee257f9aa..864ab5d2890c 100644 --- a/arch/s390/include/asm/ipl.h +++ b/arch/s390/include/asm/ipl.h @@ -122,7 +122,7 @@ struct ipl_report_certificate { struct kexec_buf; struct ipl_report *ipl_report_init(struct ipl_parameter_block *ipib); -void *ipl_report_finish(struct ipl_report *report); +int ipl_report_finish(struct ipl_report *report, void **ipl_buf); int ipl_report_free(struct ipl_report *report); int ipl_report_add_component(struct ipl_report *report, struct kexec_buf *kbuf, unsigned char flags, unsigned short cert); diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c index e2cc35775b99..a0af0b23148d 100644 --- a/arch/s390/kernel/ipl.c +++ b/arch/s390/kernel/ipl.c @@ -2144,7 +2144,7 @@ struct ipl_report *ipl_report_init(struct ipl_parameter_block *ipib) return report; } -void *ipl_report_finish(struct ipl_report *report) +int ipl_report_finish(struct ipl_report *report, void **ipl_buf) { struct ipl_report_certificate *cert; struct ipl_report_component *comp; @@ -2195,7 +2195,9 @@ void *ipl_report_finish(struct ipl_report *report) } BUG_ON(ptr > buf + report->size); - return buf; + *ipl_buf = buf; + + return 0; } int ipl_report_free(struct ipl_report *report) diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c index 528edff085d9..17e961975624 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -170,6 +170,7 @@ static int kexec_file_add_ipl_report(struct kimage *image, struct kexec_buf buf; unsigned long addr; void *ptr, *end; + int ret; buf.image = image; @@ -199,7 +200,9 @@ static int kexec_file_add_ipl_report(struct kimage *image, ptr += len; } - buf.buffer = ipl_report_finish(data->report); + ret = ipl_report_finish(data->report, &buf.buffer); + if (ret) + return ret; buf.bufsz = data->report->size; buf.memsz = buf.bufsz; -- 2.17.2 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2021-11-16 3:27 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-16 3:25 Baoquan He [this message] 2021-11-16 3:25 ` [PATCH v2 1/2] s390/kexec: check the return value of ipl_report_finish Baoquan He 2021-11-16 3:25 ` [PATCH v2 2/2] s390/kexec: fix kmemleak Baoquan He 2021-11-16 3:25 ` Baoquan He 2021-11-16 3:31 ` [PATCH v2 RESEND 2/2] s390/kexec: fix memory leak of ipl report buffer Baoquan He 2021-11-16 3:31 ` Baoquan He 2021-11-16 11:17 ` Heiko Carstens 2021-11-16 11:17 ` Heiko Carstens 2021-11-17 21:46 ` [PATCH v2 2/2] s390/kexec: fix kmemleak kernel test robot 2021-11-17 21:46 ` kernel test robot 2021-11-18 7:13 ` Baoquan He 2021-11-18 7:13 ` Baoquan He 2021-11-18 7:13 ` Baoquan He 2021-11-18 8:53 ` Heiko Carstens 2021-11-18 8:53 ` Heiko Carstens 2021-11-18 8:53 ` Heiko Carstens 2021-11-19 2:35 ` Baoquan He 2021-11-19 2:35 ` Baoquan He 2021-11-19 2:35 ` Baoquan He 2021-11-16 11:17 ` [PATCH v2 1/2] s390/kexec: check the return value of ipl_report_finish Heiko Carstens 2021-11-16 11:17 ` Heiko Carstens 2021-11-16 13:39 ` Baoquan He 2021-11-16 13:39 ` Baoquan He 2021-11-26 8:21 ` kernel test robot 2021-11-26 8:21 ` kernel test robot 2021-11-26 8:21 ` kernel test robot 2021-11-26 9:36 ` Baoquan He 2021-11-26 9:36 ` Baoquan He 2021-11-26 9:36 ` Baoquan He
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211116032557.14075-1-bhe@redhat.com \ --to=bhe@redhat.com \ --cc=hca@linux.ibm.com \ --cc=kexec@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-s390@vger.kernel.org \ --cc=prudo@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.