mbedtls: fix defects in coverity scan

Fixes of unreleased buffer, deadcode and wrong variable type detected
by coverity scan.

Addresses-Coverity-ID: 510809:  Resource leaks  (RESOURCE_LEAK)
Addresses-Coverity-ID: 510806:  Control flow issues  (DEADCODE)
Addresses-Coverity-ID: 510794 Control flow issues  (NO_EFFECT)

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
diff --git a/lib/mbedtls/pkcs7_parser.c b/lib/mbedtls/pkcs7_parser.c
index 69ca784..ecfcc46 100644
--- a/lib/mbedtls/pkcs7_parser.c
+++ b/lib/mbedtls/pkcs7_parser.c
@@ -206,9 +206,6 @@
 		p += seq_len;
 	}
 
-	if (ret && ret !=  MBEDTLS_ERR_ASN1_OUT_OF_DATA)
-		return ret;
-
 	msg->have_authattrs = true;
 
 	/*
@@ -361,8 +358,10 @@
 	signed_info->sig = s;
 
 	/* Save the Authenticate Attributes data if exists */
-	if (!mb_sinfo->authattrs.data || !mb_sinfo->authattrs.data_len)
+	if (!mb_sinfo->authattrs.data || !mb_sinfo->authattrs.data_len) {
+		kfree(mctx);
 		goto no_authattrs;
+	}
 
 	mctx->authattrs_data = kmemdup(mb_sinfo->authattrs.data,
 				       mb_sinfo->authattrs.data_len,