[PATCH v2] crypto/openssl: fix memory leaks in asym ops

Stephen Hemminger stephen at networkplumber.org
Thu Nov 2 23:47:18 CET 2023


On Thu, 2 Nov 2023 14:08:31 +0530
Gowrishankar Muthukrishnan <gmuthukrishn at marvell.com> wrote:

> +	if (pub_key)
> +		BN_free(pub_key);
> +	if (pkey)
> +		EVP_PKEY_free(pkey);
>  

All these checks for null are unnecessary:

       EVP_PKEY_free() decrements the reference count of key and, if the reference count is zero,
       frees it up. If key is NULL, nothing is done.


Let me add those functions to cocci nullfree script as well.



More information about the dev mailing list