From patchwork Wed Jul 13 06:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 113931 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 EA66BA0032; Wed, 13 Jul 2022 08:44:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 937B24282D; Wed, 13 Jul 2022 08:44:48 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 679A54282B for ; Wed, 13 Jul 2022 08:44:47 +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 26D2MJbc026765; Tue, 12 Jul 2022 23:44:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Q6D2LyTx3cz5f6BiAIaufUuGEjrOqDa05iiwm7GDwas=; b=CRU6UthzA6i+X37dSprAe90mDYfyaA2PAUMcsVKhK3D+uQB5JTBBPVzWyX26/o3iZ10h oH0wJ0xo4hKpw3q+R/B+sLVj0iyE5i7mlizk7bqzn17syflWiYW0pwl9AzR0HDI5cLbI 3wkd/R2B90UUOQwYk1rQKhvCIG7/DKSY/Z2sTlJbEvrK9i+Ia3w+Ca39qwIVP9I1lYIW /u55VORNBUTc/JuSdOriGO1TLN6HxbOeKzP1viPhtLqVixc5JGdbTNKJgB3AJN9d52BU MEteJgiMUo4ZLrsRst04jcpfmpvC6BexNMGH1nBlh9hEa64lMctix3hUh9XFc2xx7Sj+ Dg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h9n6n0qc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 23:44:46 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 12 Jul 2022 23:44:44 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Tue, 12 Jul 2022 23:44:44 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 114943F7084; Tue, 12 Jul 2022 23:44:41 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Akhil Goyal , Fan Zhang , Brian Dooley , Anoob Joseph , Archana Muniganti , Jerin Jacob , Gowrishankar Muthukrishnan Subject: [PATCH v1] examples/fips_validation: fix memory allocation in aes mct test Date: Wed, 13 Jul 2022 12:14:39 +0530 Message-ID: <20220713064439.3990811-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: U4Y3YMBJDVmWgQ0Io32WWuwhwGi8yDms X-Proofpoint-GUID: U4Y3YMBJDVmWgQ0Io32WWuwhwGi8yDms 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-07-12_14,2022-07-12_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 --- 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 5e65c5e193..8babbb3298 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -1588,9 +1588,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) @@ -1622,16 +1625,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) { @@ -1670,12 +1665,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)); @@ -1706,6 +1697,9 @@ fips_mct_aes_test(void) } free(val[0].val); + free(pt.val); + free(ct.val); + free(iv.val); return 0; }