[PATCH] net/iavf: fix null pointer dereference

Zhang, Qi Z qi.z.zhang at intel.com
Fri Jan 28 09:50:53 CET 2022



> -----Original Message-----
> From: Weiguo Li <liwg06 at foxmail.com>
> Sent: Tuesday, January 25, 2022 10:23 PM
> To: Wu, Jingjing <jingjing.wu at intel.com>
> Cc: Nicolau, Radu <radu.nicolau at intel.com>; dev at dpdk.org
> Subject: [PATCH] net/iavf: fix null pointer dereference
> 
> Check for memory allocation failure is added to avoid null pointer
> dereference.
> 
> Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto")
> 
> Signed-off-by: Weiguo Li <liwg06 at foxmail.com>
> ---
>  drivers/net/iavf/iavf_ipsec_crypto.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c
> b/drivers/net/iavf/iavf_ipsec_crypto.c
> index adf101ab8a..ac67aa28f7 100644
> --- a/drivers/net/iavf/iavf_ipsec_crypto.c
> +++ b/drivers/net/iavf/iavf_ipsec_crypto.c
> @@ -1352,6 +1352,8 @@ iavf_ipsec_crypto_set_security_capabililites(struct
> iavf_security_ctx
>  	capabilities = rte_zmalloc("crypto_cap",
>  		sizeof(struct rte_cryptodev_capabilities) *
>  		(number_of_capabilities + 1), 0);
> +	if (!capabilities)
> +		return (-ENOMEM);

Better to unwrap the bracket to keep coding style consistent 

>  	capabilities[number_of_capabilities].op =
> RTE_CRYPTO_OP_TYPE_UNDEFINED;
> 
>  	/**
> --
> 2.25.1



More information about the dev mailing list