patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] crypto/qat: fix allocation check and leak
@ 2018-02-08 11:49 Yong Wang
  2018-02-08 14:13 ` Luca Boccassi
  0 siblings, 1 reply; 3+ messages in thread
From: Yong Wang @ 2018-02-08 11:49 UTC (permalink / raw)
  To: stable; +Cc: wang.yong19

[ 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 <wang.yong19@zte.com.cn>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH] crypto/qat: fix allocation check and leak
  2018-02-08 11:49 [dpdk-stable] [PATCH] crypto/qat: fix allocation check and leak Yong Wang
@ 2018-02-08 14:13 ` Luca Boccassi
  0 siblings, 0 replies; 3+ messages in thread
From: Luca Boccassi @ 2018-02-08 14:13 UTC (permalink / raw)
  To: Yong Wang, stable

On Thu, 2018-02-08 at 06:49 -0500, Yong Wang wrote:
> [ 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 <wang.yong19@zte.com.cn>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  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) {

Applied to dpdk-stable/16.11 (will be pushed soon), thanks.

-- 
Kind regards,
Luca Boccassi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [PATCH] crypto/qat: fix allocation check and leak
@ 2018-02-08 11:47 Yong Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Yong Wang @ 2018-02-08 11:47 UTC (permalink / raw)
  To: wang.yong19; +Cc: stable

[ 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 <wang.yong19@zte.com.cn>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-08 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 11:49 [dpdk-stable] [PATCH] crypto/qat: fix allocation check and leak Yong Wang
2018-02-08 14:13 ` Luca Boccassi
  -- strict thread matches above, loose matches on Subject: below --
2018-02-08 11:47 Yong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).