--- eng_cryptodev.c.orig	2015-09-11 20:27:00.633000000 -0700
+++ eng_cryptodev.c	2015-09-11 20:28:29.433000000 -0700
@@ -937,6 +937,10 @@
     if (fstate->mac_len != 0) {
         if (fstate->mac_data != NULL) {
             dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
+	    if (dstate->mac_data == NULL) {
+		printf("cryptodev_digest_init: Memory allocation failed\n");
+		return (0);
+	    }
             memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
             dstate->mac_len = fstate->mac_len;
         }
