[Skiboot] [PATCH 2/2] phb4: Handle allocation errors in phb4_eeh_dump_regs()

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue Aug 21 14:27:15 AEST 2018


If the zalloc fails (and it can be a rather large allocation),
we will overwite memory at 0 instead of failing.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 hw/phb4.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/phb4.c b/hw/phb4.c
index 8b8668cf..41c3e9cc 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -2072,6 +2072,10 @@ static void phb4_eeh_dump_regs(struct phb4 *p)
 		return;
 
 	s = zalloc(sizeof(struct OpalIoPhb4ErrorData));
+	if (!s) {
+		PHBERR(p, "Failed to allocate error info !\n");
+		return;
+	}
 	phb4_read_phb_status(p, s);
 
 
-- 
2.17.1



More information about the Skiboot mailing list