From patchwork Fri Aug 12 11:47:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 114907 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3FFEFA0543; Fri, 12 Aug 2022 13:47:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CFEE406A2; Fri, 12 Aug 2022 13:47:20 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EE13D40685 for ; Fri, 12 Aug 2022 13:47:18 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27C8KdbS007657; Fri, 12 Aug 2022 04:47:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=PYlSW1Wcj3xJ5joXi2fyyvNnfm45PmzzqIgTwl0c3c8=; b=IV6Oqaj8YjkYvAFNXrSSzo6fwhpkszFBdXpS8/jHLzUYPhkeHi3YZIDu8VOpLlI/3OPz bxs/9qlK4/KlBlNddtePAsVnfXvfzv/ZFLZEqrwHueyyz9O3nEsDotlTnNjhHsBKimc+ uD1lQhpThLmShQ6ZsI+OdffK3cSSnbffcEghowejeWmJ3yb4QXluVpMkvor1Awdd0gtv 0gyzVeobqvEVzOTNrGj8Eqwfxy2cuHVLVXMkrM3QX5oQ4GlEHQ6RZj2+iI0JAtMFy1Ak OxuAOhSCGus6+ShRWPC7Ja4tA5FbvJe7aPfAOeIcXlvoSiMGoE7yJQQ5nYI/vaeSz5N8 sQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3hwk8wgjng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 04:47:18 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 12 Aug 2022 04:47:16 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 12 Aug 2022 04:47:16 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 13E8E5B6936; Fri, 12 Aug 2022 04:47:13 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , Fan Zhang , Brian Dooley , Akhil Goyal , Gowrishankar Muthukrishnan Subject: [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test Date: Fri, 12 Aug 2022 17:17:10 +0530 Message-ID: <20220812114710.1032171-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713064439.3990811-1-gmuthukrishn@marvell.com> References: <20220713064439.3990811-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 4Ym_yW1-wcaEN4oXmxaY4vaAUg4CUA86 X-Proofpoint-ORIG-GUID: 4Ym_yW1-wcaEN4oXmxaY4vaAUg4CUA86 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-12_08,2022-08-11_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Instead of allocating memory in every external iteration, do once in the beginning of AES MCT tests and free at the end. Fixes: 8b8546aaedf ("examples/fips_validation: add parsing for AES-CBC") Signed-off-by: Gowrishankar Muthukrishnan Acked-by: Brian Dooley --- v2: - commit message. --- examples/fips_validation/main.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index 8bd5a66889..5c3f79a91c 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -1565,9 +1565,12 @@ fips_mct_aes_test(void) if (info.interim_info.aes_data.cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) return fips_mct_aes_ecb_test(); - memset(&pt, 0, sizeof(struct fips_val)); - memset(&ct, 0, sizeof(struct fips_val)); - memset(&iv, 0, sizeof(struct fips_val)); + pt.len = vec.pt.len; + pt.val = calloc(1, pt.len); + ct.len = vec.ct.len; + ct.val = calloc(1, ct.len); + iv.len = vec.iv.len; + iv.val = calloc(1, iv.len); for (i = 0; i < AES_EXTERN_ITER; i++) { if (info.file_type != FIPS_TYPE_JSON) { if (i != 0) @@ -1599,16 +1602,8 @@ fips_mct_aes_test(void) if (j == 0) { memcpy(prev_out, val[0].val, AES_BLOCK_SIZE); - pt.len = vec.pt.len; - pt.val = calloc(1, pt.len); memcpy(pt.val, vec.pt.val, pt.len); - - ct.len = vec.ct.len; - ct.val = calloc(1, ct.len); memcpy(ct.val, vec.ct.val, ct.len); - - iv.len = vec.iv.len; - iv.val = calloc(1, iv.len); memcpy(iv.val, vec.iv.val, iv.len); if (info.op == FIPS_TEST_ENC_AUTH_GEN) { @@ -1647,12 +1642,8 @@ fips_mct_aes_test(void) if (info.file_type != FIPS_TYPE_JSON) fprintf(info.fp_wr, "\n"); - if (i == AES_EXTERN_ITER - 1) { - free(pt.val); - free(ct.val); - free(iv.val); + if (i == AES_EXTERN_ITER - 1) continue; - } /** update key */ memcpy(&val_key, &vec.cipher_auth.key, sizeof(val_key)); @@ -1683,6 +1674,9 @@ fips_mct_aes_test(void) } free(val[0].val); + free(pt.val); + free(ct.val); + free(iv.val); return 0; }