core: Handle exhaution of message contexts

If message contexts are exhausted, there is a possibility of
NULL pointer dereference. Close this attack surface with a
check on the message context creation status.

Signed-off-by: Sumanth Bhat <sumanth.bhat@linux.intel.com>
Change-Id: I208349b74a27a14b180c976bd78ec81a7991e43f
diff --git a/core.c b/core.c
index 2ab5d5f..1050c4d 100644
--- a/core.c
+++ b/core.c
@@ -544,6 +544,12 @@
 		} else {
 			ctx = mctp_msg_ctx_create(mctp,
 					hdr->src, hdr->dest, tag);
+			/* If context creation fails due to exhaution of contexts we
+			* can support, drop the packet */
+			if (!ctx) {
+				mctp_prdebug("Context buffers exhausted.");
+				goto out;
+			}
 		}
 
 		/* Save the fragment size, subsequent middle fragments