From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mxct.zte.com.cn (out1.zte.com.cn [202.103.147.172]) by dpdk.org (Postfix) with ESMTP id EC2EC1B7C3 for ; Thu, 8 Feb 2018 13:09:32 +0100 (CET) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 1452B8D60515A6B97871 for ; Thu, 8 Feb 2018 20:09:30 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w18C9MGl038316 for ; Thu, 8 Feb 2018 20:09:22 +0800 (GMT-8) (envelope-from wang.yong19@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.43.166.165]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018020820093058-4205149 ; Thu, 8 Feb 2018 20:09:30 +0800 From: Yong Wang To: wang.yong19@zte.com.cn Cc: stable@dpdk.org Date: Thu, 8 Feb 2018 06:47:48 -0500 Message-Id: <1518090468-8928-1-git-send-email-wang.yong19@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-02-08 20:09:30, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-02-08 20:09:10, Serialize complete at 2018-02-08 20:09:10 X-MAIL: mse01.zte.com.cn w18C9MGl038316 Subject: [dpdk-stable] [PATCH] crypto/qat: fix allocation check and leak X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 12:09:33 -0000 [ backported from upstream commit 963898f0e316611df9dc2964d059b4e16835b95a ] There are several func calls to rte_zmalloc() which don't do null point check on the return value. Fix it by adding null point check. Fixes: 1703e94ac5ce ("qat: add driver for QuickAssist devices") Cc: stable@dpdk.org Signed-off-by: Yong Wang Acked-by: Fiona Trahe Acked-by: Ferruh Yigit --- drivers/crypto/qat/qat_adf/qat_algs_build_desc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c index 1c4b184..ac9d822 100644 --- a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c +++ b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c @@ -334,6 +334,11 @@ static int qat_alg_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, in = rte_zmalloc("working mem for key", ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ, 16); + if (in == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc memory"); + return -ENOMEM; + } + rte_memcpy(in, qat_aes_xcbc_key_seed, ICP_QAT_HW_AES_XCBC_MAC_STATE2_SZ); for (x = 0; x < HASH_XCBC_PRECOMP_KEY_NUM; x++) { @@ -364,6 +369,11 @@ static int qat_alg_do_precomputes(enum icp_qat_hw_auth_algo hash_alg, ICP_QAT_HW_GALOIS_E_CTR0_SZ); in = rte_zmalloc("working mem for key", ICP_QAT_HW_GALOIS_H_SZ, 16); + if (in == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc memory"); + return -ENOMEM; + } + memset(in, 0, ICP_QAT_HW_GALOIS_H_SZ); if (AES_set_encrypt_key(auth_key, auth_keylen << 3, &enc_key) != 0) { -- 1.8.3.1