[Skiboot] [PATCH] FSP: Validate fsp_msg response memory allocation

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Sun Jul 3 00:47:06 AEST 2016


fsp_allocmsg() returns true even if msg->resp memory allocation fails.
Validate msg->resp memory allocation as well.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hw/fsp/fsp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c
index 888da88..26cad63 100644
--- a/hw/fsp/fsp.c
+++ b/hw/fsp/fsp.c
@@ -249,8 +249,14 @@ struct fsp_msg *fsp_allocmsg(bool alloc_response)
 	msg = __fsp_allocmsg();
 	if (!msg)
 		return NULL;
-	if (alloc_response)
+	if (alloc_response) {
 		msg->resp = __fsp_allocmsg();
+		if (!msg->resp) {
+			free(msg);
+			return NULL;
+		}
+	}
+
 	return msg;
 }
 



More information about the Skiboot mailing list