[dpdk-dev] [PATCH] cryptodev: fix NULL pointer dereference

Sergio Gonzalez Monroy sergio.gonzalez.monroy at intel.com
Mon Jul 31 14:32:58 CEST 2017


On 31/07/2017 03:30, Pablo de Lara wrote:
> When registering a crypto driver, if memory allocation
> fails, application should exit and do not allow
> a NULL pointer dereference.
>
> Coverity issue: 158645
>
> Fixes: 7a364faef185 ("cryptodev: remove crypto device type enumeration")
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch at intel.com>
> ---
>   lib/librte_cryptodev/rte_cryptodev.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
> index 327d7e8..4492b0d 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.c
> +++ b/lib/librte_cryptodev/rte_cryptodev.c
> @@ -1404,6 +1404,12 @@ rte_cryptodev_allocate_driver(const struct rte_driver *drv)
>   	struct cryptodev_driver *driver;
>   
>   	driver = malloc(sizeof(*driver));
> +
> +	if (driver == NULL)
> +		rte_exit(EXIT_FAILURE,
> +			"Could not allocate memory for crypto driver %u\n",
> +			nb_drivers);
> +
>   	driver->driver = drv;
>   	driver->id = nb_drivers;
>   

Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy at intel.com>



More information about the dev mailing list